Skip to content

Commit 04a383c

Browse files
mchehabJonathan Corbet
authored andcommitted
scripts/kernel-doc.py: Rename the kernel doc Re class to KernRe
Using just "Re" makes it harder to distinguish from the native "re" class. So, let's rename it. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/4e095ecd5235a3e811ddcf5bad4cfb92f1da0a4a.1744106242.git.mchehab+huawei@kernel.org
1 parent 16740c2 commit 04a383c

File tree

3 files changed

+159
-159
lines changed

3 files changed

+159
-159
lines changed

scripts/lib/kdoc/kdoc_output.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,31 @@
2020
from datetime import datetime
2121

2222
from kdoc_parser import KernelDoc, type_param
23-
from kdoc_re import Re
23+
from kdoc_re import KernRe
2424

2525

26-
function_pointer = Re(r"([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)", cache=False)
26+
function_pointer = KernRe(r"([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)", cache=False)
2727

2828
# match expressions used to find embedded type information
29-
type_constant = Re(r"\b``([^\`]+)``\b", cache=False)
30-
type_constant2 = Re(r"\%([-_*\w]+)", cache=False)
31-
type_func = Re(r"(\w+)\(\)", cache=False)
32-
type_param_ref = Re(r"([\!~\*]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)", cache=False)
29+
type_constant = KernRe(r"\b``([^\`]+)``\b", cache=False)
30+
type_constant2 = KernRe(r"\%([-_*\w]+)", cache=False)
31+
type_func = KernRe(r"(\w+)\(\)", cache=False)
32+
type_param_ref = KernRe(r"([\!~\*]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)", cache=False)
3333

3434
# Special RST handling for func ptr params
35-
type_fp_param = Re(r"\@(\w+)\(\)", cache=False)
35+
type_fp_param = KernRe(r"\@(\w+)\(\)", cache=False)
3636

3737
# Special RST handling for structs with func ptr params
38-
type_fp_param2 = Re(r"\@(\w+->\S+)\(\)", cache=False)
38+
type_fp_param2 = KernRe(r"\@(\w+->\S+)\(\)", cache=False)
3939

40-
type_env = Re(r"(\$\w+)", cache=False)
41-
type_enum = Re(r"\&(enum\s*([_\w]+))", cache=False)
42-
type_struct = Re(r"\&(struct\s*([_\w]+))", cache=False)
43-
type_typedef = Re(r"\&(typedef\s*([_\w]+))", cache=False)
44-
type_union = Re(r"\&(union\s*([_\w]+))", cache=False)
45-
type_member = Re(r"\&([_\w]+)(\.|->)([_\w]+)", cache=False)
46-
type_fallback = Re(r"\&([_\w]+)", cache=False)
47-
type_member_func = type_member + Re(r"\(\)", cache=False)
40+
type_env = KernRe(r"(\$\w+)", cache=False)
41+
type_enum = KernRe(r"\&(enum\s*([_\w]+))", cache=False)
42+
type_struct = KernRe(r"\&(struct\s*([_\w]+))", cache=False)
43+
type_typedef = KernRe(r"\&(typedef\s*([_\w]+))", cache=False)
44+
type_union = KernRe(r"\&(union\s*([_\w]+))", cache=False)
45+
type_member = KernRe(r"\&([_\w]+)(\.|->)([_\w]+)", cache=False)
46+
type_fallback = KernRe(r"\&([_\w]+)", cache=False)
47+
type_member_func = type_member + KernRe(r"\(\)", cache=False)
4848

4949

5050
class OutputFormat:
@@ -257,8 +257,8 @@ class RestFormat(OutputFormat):
257257
]
258258
blankline = "\n"
259259

260-
sphinx_literal = Re(r'^[^.].*::$', cache=False)
261-
sphinx_cblock = Re(r'^\.\.\ +code-block::', cache=False)
260+
sphinx_literal = KernRe(r'^[^.].*::$', cache=False)
261+
sphinx_cblock = KernRe(r'^\.\.\ +code-block::', cache=False)
262262

263263
def __init__(self):
264264
"""
@@ -299,14 +299,14 @@ def output_highlight(self, args):
299299
# If this is the first non-blank line in a literal block,
300300
# figure out the proper indent.
301301
if not litprefix:
302-
r = Re(r'^(\s*)')
302+
r = KernRe(r'^(\s*)')
303303
if r.match(line):
304304
litprefix = '^' + r.group(1)
305305
else:
306306
litprefix = ""
307307

308308
output += line + "\n"
309-
elif not Re(litprefix).match(line):
309+
elif not KernRe(litprefix).match(line):
310310
in_literal = False
311311
else:
312312
output += line + "\n"
@@ -429,7 +429,7 @@ def out_function(self, fname, name, args):
429429
self.data += f"{self.lineprefix}**Parameters**\n\n"
430430

431431
for parameter in parameterlist:
432-
parameter_name = Re(r'\[.*').sub('', parameter)
432+
parameter_name = KernRe(r'\[.*').sub('', parameter)
433433
dtype = args['parametertypes'].get(parameter, "")
434434

435435
if dtype:
@@ -626,7 +626,7 @@ def output_highlight(self, block):
626626
contents = "\n".join(contents)
627627

628628
for line in contents.strip("\n").split("\n"):
629-
line = Re(r"^\s*").sub("", line)
629+
line = KernRe(r"^\s*").sub("", line)
630630
if not line:
631631
continue
632632

@@ -680,7 +680,7 @@ def out_function(self, fname, name, args):
680680
# Pointer-to-function
681681
self.data += f'".BI "{parenth}{function_pointer.group(1)}" " ") ({function_pointer.group(2)}){post}"' + "\n"
682682
else:
683-
dtype = Re(r'([^\*])$').sub(r'\1 ', dtype)
683+
dtype = KernRe(r'([^\*])$').sub(r'\1 ', dtype)
684684

685685
self.data += f'.BI "{parenth}{dtype}" "{post}"' + "\n"
686686
count += 1
@@ -727,7 +727,7 @@ def out_enum(self, fname, name, args):
727727
self.data += ".SH Constants\n"
728728

729729
for parameter in parameterlist:
730-
parameter_name = Re(r'\[.*').sub('', parameter)
730+
parameter_name = KernRe(r'\[.*').sub('', parameter)
731731
self.data += f'.IP "{parameter}" 12' + "\n"
732732
self.output_highlight(args['parameterdescs'].get(parameter_name, ""))
733733

@@ -769,7 +769,7 @@ def out_struct(self, fname, name, args):
769769

770770
# Replace tabs with two spaces and handle newlines
771771
declaration = definition.replace("\t", " ")
772-
declaration = Re(r"\n").sub('"\n.br\n.BI "', declaration)
772+
declaration = KernRe(r"\n").sub('"\n.br\n.BI "', declaration)
773773

774774
self.data += ".SH SYNOPSIS\n"
775775
self.data += f"{struct_type} {struct_name} " + "{" + "\n.br\n"

0 commit comments

Comments
 (0)