History

docs: kdoc_parser: don't mangle with function defines

Mangling with #defines is not nice, as we may end removing the macro names, preventing several macros from being properly documented. Also, on defines, we have something like: #define foo(a1, a2, a3, ...) \ /* some real implementation */ The prototype part (first line on this example) won't contain any macros, so no need to apply any regexes on it. With that, move the apply_transforms() logic to ensure that it will be called only on functions.

Mauro Carvalho Chehab committed 8 months ago

Commit cca1bbd1 parent 77e6e171 file · +7 −5Browse files

Showing the changes to tools/lib/python (1 of 1 file). Show all

Unified · Split

tools/lib/python/kdoc/kdoc_parser.py+7−5
@@ -163,7 +163,7 @@ struct_nested_prefixes = [ · 162 unmodified lines
163#163#
164# Transforms for function prototypes164# Transforms for function prototypes
165#165#
166function_xforms = [166function_xforms = [
167 (KernRe(r"^static +"), ""),167 (KernRe(r"^static +"), ""),
168 (KernRe(r"^extern +"), ""),168 (KernRe(r"^extern +"), ""),
169 (KernRe(r"^asmlinkage +"), ""),169 (KernRe(r"^asmlinkage +"), ""),
@@ -1066,10 +1066,7 @@ class KernelDoc: · 896 unmodified lines
1066 found = func_macro = False1066 found = func_macro = False
1067 return_type = ''1067 return_type = ''
1068 decl_type = 'function'1068 decl_type = 'function'
1069 #1069
1070 # Apply the initial transformations.
1071 #
1072 prototype = apply_transforms(function_xforms, prototype)
1073 #1070 #
1074 # If we have a macro, remove the "#define" at the front.1071 # If we have a macro, remove the "#define" at the front.
1075 #1072 #
@@ -1088,6 +1085,11 @@ class KernelDoc: · 12 unmodified lines
1088 declaration_name = r.group(1)1085 declaration_name = r.group(1)
1089 func_macro = True1086 func_macro = True
1090 found = True1087 found = True
1088 else:
1089 #
1090 # Apply the initial transformations.
1091 #
1092 prototype = apply_transforms(function_xforms, prototype)
1091 1093
1092 # Yes, this truly is vile. We are looking for:1094 # Yes, this truly is vile. We are looking for:
1093 # 1. Return type (may be nothing if we're looking at a macro)1095 # 1. Return type (may be nothing if we're looking at a macro)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t