Skip to content

Commit c02014f

Browse files
[NFC][SYCL] Re-format python files using "black"
intel#12184 enable format check for python files but we never properly formatted them. Do it now.
1 parent a6d3445 commit c02014f

File tree

11 files changed

+3182
-1863
lines changed

11 files changed

+3182
-1863
lines changed

sycl/doc/conf.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,67 +21,68 @@
2121

2222
now = datetime.datetime.now()
2323

24-
project = 'oneAPI DPC++ Compiler'
25-
copyright = str(now.year) + ', Intel Corporation'
26-
author = 'Intel Corporation'
24+
project = "oneAPI DPC++ Compiler"
25+
copyright = str(now.year) + ", Intel Corporation"
26+
author = "Intel Corporation"
2727

2828
# -- General configuration ---------------------------------------------------
2929

30-
master_doc = 'index'
30+
master_doc = "index"
3131

3232
# Add any Sphinx extension module names here, as strings. They can be
3333
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3434
# ones.
35-
extensions = [
36-
'myst_parser'
37-
]
35+
extensions = ["myst_parser"]
3836

3937
# Implicit targets for cross reference
4038
myst_heading_anchors = 5
4139

4240
# The name of the Pygments (syntax highlighting) style to use.
43-
pygments_style = 'friendly'
41+
pygments_style = "friendly"
4442

4543
# The theme to use for HTML and HTML Help pages. See the documentation for
4644
# a list of builtin themes.
47-
html_theme = 'haiku'
45+
html_theme = "haiku"
4846

4947
# The suffix of source filenames.
50-
source_suffix = ['.rst', '.md']
48+
source_suffix = [".rst", ".md"]
5149

5250
exclude_patterns = [
5351
# Extensions are mostly in asciidoc which has poor support in Sphinx.
54-
'extensions/*',
55-
'design/opencl-extensions/*',
56-
'design/spirv-extensions/*',
57-
52+
"extensions/*",
53+
"design/opencl-extensions/*",
54+
"design/spirv-extensions/*",
5855
# Sphinx complains about syntax errors in these files.
59-
'design/DeviceLibExtensions.rst',
60-
'design/SYCLPipesLoweringToSPIRV.rst',
61-
'design/fpga_io_pipes_design.rst',
62-
'design/Reduction_status.md'
56+
"design/DeviceLibExtensions.rst",
57+
"design/SYCLPipesLoweringToSPIRV.rst",
58+
"design/fpga_io_pipes_design.rst",
59+
"design/Reduction_status.md",
6360
]
6461

65-
suppress_warnings = [ 'misc.highlighting_failure' ]
62+
suppress_warnings = ["misc.highlighting_failure"]
63+
6664

6765
def on_missing_reference(app, env, node, contnode):
6866
# Get the directory that contains the *source* file of the link. These
6967
# files are always relative to the directory containing "conf.py"
7068
# (<top>/sycl/doc). For example, the file "sycl/doc/design/foo.md" will
7169
# have a directory "design".
72-
refdoc_components = node['refdoc'].split('/')
73-
dirs = '/'.join(refdoc_components[:-1])
74-
if dirs: dirs += '/'
70+
refdoc_components = node["refdoc"].split("/")
71+
dirs = "/".join(refdoc_components[:-1])
72+
if dirs:
73+
dirs += "/"
7574

7675
# A missing reference usually occurs when the target file of the link is
7776
# not processed by Sphinx. Compensate by creating a link that goes to the
7877
# file's location in the GitHub repo.
79-
new_target = "https://github.com/intel/llvm/tree/sycl/sycl/doc/" + dirs + \
80-
node['reftarget']
78+
new_target = (
79+
"https://github.com/intel/llvm/tree/sycl/sycl/doc/" + dirs + node["reftarget"]
80+
)
8181

82-
newnode = nodes.reference('', '', internal=False, refuri=new_target)
82+
newnode = nodes.reference("", "", internal=False, refuri=new_target)
8383
newnode.append(contnode)
8484
return newnode
8585

86+
8687
def setup(app):
87-
app.connect('missing-reference', on_missing_reference)
88+
app.connect("missing-reference", on_missing_reference)
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import re
22
import sys
33

4+
45
def camel_to_snake(src):
5-
return re.sub(r'(?<!^)(?=[A-Z])', '_', src).lower()
6+
return re.sub(r"(?<!^)(?=[A-Z])", "_", src).lower()
7+
68

79
def snake_to_camel(src):
8-
temp = src.split('_')
9-
return ''.join(x.title() for x in temp)
10+
temp = src.split("_")
11+
return "".join(x.title() for x in temp)
1012

1113

1214
def extract_ze_apis(header):
@@ -16,25 +18,31 @@ def extract_ze_apis(header):
1618
"""
1719
api = open("ze_api.def", "w")
1820

19-
matches = re.finditer(r'typedef struct _ze_([_a-z]+)_callbacks_t\n\{\n([a-zA-Z_;\s\n]+)\n\} ze_([_a-z]+)_callbacks_t;', header)
21+
matches = re.finditer(
22+
r"typedef struct _ze_([_a-z]+)_callbacks_t\n\{\n([a-zA-Z_;\s\n]+)\n\} ze_([_a-z]+)_callbacks_t;",
23+
header,
24+
)
2025

2126
for match in matches:
2227
api_domain = snake_to_camel(match.group(1))
2328
for l in match.group(2).splitlines():
2429
parts = l.split()
25-
api_match = re.match(r'ze_pfn([a-zA-Z]+)Cb_t', parts[0])
30+
api_match = re.match(r"ze_pfn([a-zA-Z]+)Cb_t", parts[0])
2631
api_name_tail = api_match.group(1)
27-
api_name = 'ze' + api_name_tail
32+
api_name = "ze" + api_name_tail
2833

29-
param_type = 'ze_' + camel_to_snake(api_name_tail) + '_params_t'
34+
param_type = "ze_" + camel_to_snake(api_name_tail) + "_params_t"
3035

31-
cb = 'pfn' + api_name_tail.replace(api_domain, '') + 'Cb'
36+
cb = "pfn" + api_name_tail.replace(api_domain, "") + "Cb"
3237

33-
api.write("_ZE_API({}, {}, {}, {})\n".format(api_name, api_domain, cb, param_type))
38+
api.write(
39+
"_ZE_API({}, {}, {}, {})\n".format(api_name, api_domain, cb, param_type)
40+
)
3441

3542
api.close()
3643

44+
3745
if __name__ == "__main__":
38-
with open(sys.argv[1], 'r') as f:
46+
with open(sys.argv[1], "r") as f:
3947
header = f.read()
4048
extract_ze_apis(header)

0 commit comments

Comments
 (0)