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.
Showing the changes to tools/lib/python (1 of 1 file). Show all
Unified · Split
| @@ -163,7 +163,7 @@ struct_nested_prefixes = [ · 162 unmodified lines | |||
| 163 | # | 163 | # |
| 164 | # Transforms for function prototypes | 164 | # Transforms for function prototypes |
| 165 | # | 165 | # |
| 166 | function_xforms = [ | 166 | function_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 = False | 1066 | 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 = True | 1086 | func_macro = True |
| 1090 | found = True | 1087 | 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) |