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.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -1448,31 +1448,30 @@ class KernelDoc: · 1447 unmodified lines | |||
| 1448 | # Unknown line, ignore | 1448 | # Unknown line, ignore |
| 1449 | self.emit_msg(ln, f"bad line: {line}") | 1449 | self.emit_msg(ln, f"bad line: {line}") |
| 1450 | 1450 | ||
| 1451 | def process_inline(self, ln, line): | 1451 | def process_inline_name(self, ln, line): |
| 1452 | """STATE_INLINE: docbook comments within a prototype.""" | 1452 | """STATE_INLINE_NAME: beginning of docbook comments within a prototype.""" |
| 1453 | 1453 | ||
| 1454 | if self.state == state.INLINE_NAME and \ | 1454 | if doc_inline_sect.search(line): |
| 1455 | doc_inline_sect.search(line): | ||
| 1456 | self.entry.begin_section(ln, doc_inline_sect.group(1)) | 1455 | self.entry.begin_section(ln, doc_inline_sect.group(1)) |
| 1457 | |||
| 1458 | self.entry.add_text(doc_inline_sect.group(2).lstrip()) | 1456 | self.entry.add_text(doc_inline_sect.group(2).lstrip()) |
| 1459 | self.state = state.INLINE_TEXT | 1457 | self.state = state.INLINE_TEXT |
| 1460 | # Documentation block end */ | 1458 | elif doc_inline_end.search(line): |
| 1461 | return | ||
| 1462 | |||
| 1463 | if doc_inline_end.search(line): | ||
| 1464 | self.dump_section() | 1459 | self.dump_section() |
| 1465 | self.state = state.PROTO | 1460 | self.state = state.PROTO |
| 1466 | return | 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 ... ?? | ||
| 1467 | 1465 | ||
| 1468 | if doc_content.search(line): | 1466 | def process_inline_text(self, ln, line): |
| 1469 | if self.state == state.INLINE_TEXT: | 1467 | """STATE_INLINE_TEXT: docbook comments within a prototype.""" |
| 1470 | self.entry.add_text(doc_content.group(1)) | ||
| 1471 | 1468 | ||
| 1472 | elif self.state == state.INLINE_NAME: | 1469 | if doc_inline_end.search(line): |
| 1473 | self.emit_msg(ln, | 1470 | self.dump_section() |
| 1474 | f"Incorrect use of kernel-doc format: {line}") | 1471 | self.state = state.PROTO |
| 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 | def syscall_munge(self, ln, proto): # pylint: disable=W0613 | 1476 | def syscall_munge(self, ln, proto): # pylint: disable=W0613 |
| 1478 | """ | 1477 | """ |
| @@ -1699,8 +1698,8 @@ class KernelDoc: · 220 unmodified lines | |||
| 1699 | state.BODY: process_body, | 1698 | state.BODY: process_body, |
| 1700 | state.DECLARATION: process_decl, | 1699 | state.DECLARATION: process_decl, |
| 1701 | state.SPECIAL_SECTION: process_special, | 1700 | state.SPECIAL_SECTION: process_special, |
| 1702 | state.INLINE_NAME: process_inline, | 1701 | state.INLINE_NAME: process_inline_name, |
| 1703 | state.INLINE_TEXT: process_inline, | 1702 | state.INLINE_TEXT: process_inline_text, |
| 1704 | state.PROTO: process_proto, | 1703 | state.PROTO: process_proto, |
| 1705 | state.DOCBLOCK: process_docblock, | 1704 | state.DOCBLOCK: process_docblock, |
| 1706 | } | 1705 | } |