Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: kdoc: move the function transform patterns out of dump_function()

Move these definitions to file level, where they are executed once, and
don't clutter the function itself.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>

+35 -43
+35 -43
scripts/lib/kdoc/kdoc_parser.py
··· 161 161 (re.compile(r'\bSTRUCT_GROUP\('), r'\1'), 162 162 ] 163 163 164 + # 165 + # Transforms for function prototypes 166 + # 167 + function_xforms = [ 168 + (r"^static +", "", 0), 169 + (r"^extern +", "", 0), 170 + (r"^asmlinkage +", "", 0), 171 + (r"^inline +", "", 0), 172 + (r"^__inline__ +", "", 0), 173 + (r"^__inline +", "", 0), 174 + (r"^__always_inline +", "", 0), 175 + (r"^noinline +", "", 0), 176 + (r"^__FORTIFY_INLINE +", "", 0), 177 + (r"__init +", "", 0), 178 + (r"__init_or_module +", "", 0), 179 + (r"__deprecated +", "", 0), 180 + (r"__flatten +", "", 0), 181 + (r"__meminit +", "", 0), 182 + (r"__must_check +", "", 0), 183 + (r"__weak +", "", 0), 184 + (r"__sched +", "", 0), 185 + (r"_noprof", "", 0), 186 + (r"__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +", "", 0), 187 + (r"__(?:re)?alloc_size\s*\(\s*\d+\s*(?:,\s*\d+\s*)?\) +", "", 0), 188 + (r"__diagnose_as\s*\(\s*\S+\s*(?:,\s*\d+\s*)*\) +", "", 0), 189 + (r"DECL_BUCKET_PARAMS\s*\(\s*(\S+)\s*,\s*(\S+)\s*\)", r"\1, \2", 0), 190 + (r"__attribute_const__ +", "", 0), 191 + (r"__attribute__\s*\(\((?:[\w\s]+(?:\([^)]*\))?\s*,?)+\)\)\s+", "", 0), 192 + ] 193 + 194 + 164 195 165 196 # 166 197 # A little helper to get rid of excess white space ··· 925 894 return_type = '' 926 895 decl_type = 'function' 927 896 928 - # Prefixes that would be removed 929 - sub_prefixes = [ 930 - (r"^static +", "", 0), 931 - (r"^extern +", "", 0), 932 - (r"^asmlinkage +", "", 0), 933 - (r"^inline +", "", 0), 934 - (r"^__inline__ +", "", 0), 935 - (r"^__inline +", "", 0), 936 - (r"^__always_inline +", "", 0), 937 - (r"^noinline +", "", 0), 938 - (r"^__FORTIFY_INLINE +", "", 0), 939 - (r"__init +", "", 0), 940 - (r"__init_or_module +", "", 0), 941 - (r"__deprecated +", "", 0), 942 - (r"__flatten +", "", 0), 943 - (r"__meminit +", "", 0), 944 - (r"__must_check +", "", 0), 945 - (r"__weak +", "", 0), 946 - (r"__sched +", "", 0), 947 - (r"_noprof", "", 0), 948 - (r"__printf\s*\(\s*\d*\s*,\s*\d*\s*\) +", "", 0), 949 - (r"__(?:re)?alloc_size\s*\(\s*\d+\s*(?:,\s*\d+\s*)?\) +", "", 0), 950 - (r"__diagnose_as\s*\(\s*\S+\s*(?:,\s*\d+\s*)*\) +", "", 0), 951 - (r"DECL_BUCKET_PARAMS\s*\(\s*(\S+)\s*,\s*(\S+)\s*\)", r"\1, \2", 0), 952 - (r"__attribute_const__ +", "", 0), 953 - 954 - # It seems that Python support for re.X is broken: 955 - # At least for me (Python 3.13), this didn't work 956 - # (r""" 957 - # __attribute__\s*\(\( 958 - # (?: 959 - # [\w\s]+ # attribute name 960 - # (?:\([^)]*\))? # attribute arguments 961 - # \s*,? # optional comma at the end 962 - # )+ 963 - # \)\)\s+ 964 - # """, "", re.X), 965 - 966 - # So, remove whitespaces and comments from it 967 - (r"__attribute__\s*\(\((?:[\w\s]+(?:\([^)]*\))?\s*,?)+\)\)\s+", "", 0), 968 - ] 969 - 970 - for search, sub, flags in sub_prefixes: 897 + # 898 + # Apply the initial transformations. 899 + # 900 + for search, sub, flags in function_xforms: 971 901 prototype = KernRe(search, flags).sub(sub, prototype) 972 902 973 903 # Macros are a special case, as they change the prototype format