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: coalesce the end-of-comment processing

Separate out the end-of-comment logic into its own helper and remove the
duplicated code introduced earlier.

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

+14 -22
+14 -22
scripts/lib/kdoc/kdoc_parser.py
··· 1351 1351 return True 1352 1352 return False 1353 1353 1354 - def process_decl(self, ln, line): 1355 - """ 1356 - STATE_DECLARATION: We've seen the beginning of a declaration 1357 - """ 1358 - if self.is_new_section(ln, line): 1359 - return 1360 - 1354 + # 1355 + # Helper function to detect (and effect) the end of a kerneldoc comment. 1356 + # 1357 + def is_comment_end(self, ln, line): 1361 1358 if doc_end.search(line): 1362 1359 self.dump_section() 1363 1360 ··· 1367 1370 self.entry.new_start_line = ln + 1 1368 1371 1369 1372 self.state = state.PROTO 1373 + return True 1374 + return False 1375 + 1376 + 1377 + def process_decl(self, ln, line): 1378 + """ 1379 + STATE_DECLARATION: We've seen the beginning of a declaration 1380 + """ 1381 + if self.is_new_section(ln, line) or self.is_comment_end(ln, line): 1370 1382 return 1371 1383 1372 1384 if doc_content.search(line): ··· 1412 1406 """ 1413 1407 STATE_BODY: the bulk of a kerneldoc comment. 1414 1408 """ 1415 - if self.is_new_section(ln, line): 1416 - return 1417 - 1418 - if doc_end.search(line): 1419 - self.dump_section() 1420 - 1421 - # Look for doc_com + <text> + doc_end: 1422 - r = KernRe(r'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') 1423 - if r.match(line): 1424 - self.emit_msg(ln, f"suspicious ending line: {line}") 1425 - 1426 - self.entry.prototype = "" 1427 - self.entry.new_start_line = ln + 1 1428 - 1429 - self.state = state.PROTO 1409 + if self.is_new_section(ln, line) or self.is_comment_end(ln, line): 1430 1410 return 1431 1411 1432 1412 if doc_content.search(line):