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: simplify the kerneldoc recognition code

process_name() looks for the first line of a kerneldoc comment. It
contains two nearly identical regular expressions, the second of which only
catches six cases in the kernel, all of the form:

define SOME_MACRO_NAME - description

Simply put the "define" into the regex and discard it, eliminating the loop
and the code to remove it specially.

Note that this still treats these defines as if they were functions, but
that's a separate issue.

There is no change in the generated output.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250606163438.229916-5-corbet@lwn.net

+8 -16
+8 -16
scripts/lib/kdoc/kdoc_parser.py
··· 1238 1238 1239 1239 # Test for data declaration 1240 1240 r = KernRe(r"^\s*\*?\s*(struct|union|enum|typedef)\b\s*(\w*)") 1241 + r2 = KernRe(fr"^{decl_start}{fn_type}(?:define\s+)?(\w+)\s*{parenthesis}\s*{decl_end}?$") 1241 1242 if r.search(line): 1242 1243 self.entry.decl_type = r.group(1) 1243 1244 self.entry.identifier = r.group(2) 1244 1245 self.entry.is_kernel_comment = True 1245 - else: 1246 - # Look for foo() or static void foo() - description; 1247 - # or misspelt identifier 1248 - 1249 - r1 = KernRe(fr"^{decl_start}{fn_type}(\w+)\s*{parenthesis}\s*{decl_end}?$") 1250 - r2 = KernRe(fr"^{decl_start}{fn_type}(\w+[^-:]*){parenthesis}\s*{decl_end}$") 1251 - 1252 - for r in [r1, r2]: 1253 - if r.search(line): 1254 - self.entry.identifier = r.group(1) 1255 - self.entry.decl_type = "function" 1256 - 1257 - r = KernRe(r"define\s+") 1258 - self.entry.identifier = r.sub("", self.entry.identifier) 1259 - self.entry.is_kernel_comment = True 1260 - break 1246 + # 1247 + # Look for a function description 1248 + # 1249 + elif r2.search(line): 1250 + self.entry.identifier = r2.group(1) 1251 + self.entry.decl_type = "function" 1252 + self.entry.is_kernel_comment = True 1261 1253 1262 1254 self.entry.identifier = self.entry.identifier.strip(" ") 1263 1255