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: split the processing of the two remaining inline states

Now that "inline_*" are just ordinary parser states, split them into two
separate functions, getting rid of some nested conditional logic.

The original process_inline() would simply ignore lines that didn't match
any of the regexes (those lacking the initial " * " marker). I have
preserved that behavior, but we should perhaps emit a warning instead.

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

+18 -19
+18 -19
scripts/lib/kdoc/kdoc_parser.py
··· 1448 1448 # Unknown line, ignore 1449 1449 self.emit_msg(ln, f"bad line: {line}") 1450 1450 1451 - def process_inline(self, ln, line): 1452 - """STATE_INLINE: docbook comments within a prototype.""" 1451 + def process_inline_name(self, ln, line): 1452 + """STATE_INLINE_NAME: beginning of docbook comments within a prototype.""" 1453 1453 1454 - if self.state == state.INLINE_NAME and \ 1455 - doc_inline_sect.search(line): 1454 + if doc_inline_sect.search(line): 1456 1455 self.entry.begin_section(ln, doc_inline_sect.group(1)) 1457 - 1458 1456 self.entry.add_text(doc_inline_sect.group(2).lstrip()) 1459 1457 self.state = state.INLINE_TEXT 1460 - # Documentation block end */ 1461 - return 1458 + elif doc_inline_end.search(line): 1459 + self.dump_section() 1460 + self.state = state.PROTO 1461 + elif doc_content.search(line): 1462 + self.emit_msg(ln, f"Incorrect use of kernel-doc format: {line}") 1463 + self.state = state.PROTO 1464 + # else ... ?? 1465 + 1466 + def process_inline_text(self, ln, line): 1467 + """STATE_INLINE_TEXT: docbook comments within a prototype.""" 1462 1468 1463 1469 if doc_inline_end.search(line): 1464 1470 self.dump_section() 1465 1471 self.state = state.PROTO 1466 - return 1467 - 1468 - if doc_content.search(line): 1469 - if self.state == state.INLINE_TEXT: 1470 - self.entry.add_text(doc_content.group(1)) 1471 - 1472 - elif self.state == state.INLINE_NAME: 1473 - self.emit_msg(ln, 1474 - f"Incorrect use of kernel-doc format: {line}") 1475 - self.state = state.PROTO 1472 + elif doc_content.search(line): 1473 + self.entry.add_text(doc_content.group(1)) 1474 + # else ... ?? 1476 1475 1477 1476 def syscall_munge(self, ln, proto): # pylint: disable=W0613 1478 1477 """ ··· 1698 1699 state.BODY: process_body, 1699 1700 state.DECLARATION: process_decl, 1700 1701 state.SPECIAL_SECTION: process_special, 1701 - state.INLINE_NAME: process_inline, 1702 - state.INLINE_TEXT: process_inline, 1702 + state.INLINE_NAME: process_inline_name, 1703 + state.INLINE_TEXT: process_inline_text, 1703 1704 state.PROTO: process_proto, 1704 1705 state.DOCBLOCK: process_docblock, 1705 1706 }