diff options
author | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2025-06-17 17:54:03 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2025-08-12 07:47:31 +0200 |
commit | 0b24dfdd12f4ca3ef5efa0cfaad3fc14f5b3fbf1 (patch) | |
tree | fa109f9a8482d4ad93664d088aa5eb1db4d80526 /Documentation/sphinx/parser_yaml.py | |
parent | ad06a878a328f230e9bf62ec0042eea1798d2cb0 (diff) |
docs: parser_yaml.py: add support for line numbers from the parser
Instead of printing line numbers from the temp converted ReST
file, get them from the original source.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'Documentation/sphinx/parser_yaml.py')
-rwxr-xr-x | Documentation/sphinx/parser_yaml.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Documentation/sphinx/parser_yaml.py b/Documentation/sphinx/parser_yaml.py index fa2e6da17617..8288e2ff7c7c 100755 --- a/Documentation/sphinx/parser_yaml.py +++ b/Documentation/sphinx/parser_yaml.py @@ -54,6 +54,8 @@ class YamlParser(Parser): netlink_parser = YnlDocGenerator() + re_lineno = re.compile(r"\.\. LINENO ([0-9]+)$") + def rst_parse(self, inputstring, document, msg): """ Receives a ReST content that was previously converted by the @@ -66,8 +68,14 @@ class YamlParser(Parser): try: # Parse message with RSTParser - for i, line in enumerate(msg.split('\n')): - result.append(line, document.current_source, i) + lineoffset = 0; + for line in msg.split('\n'): + match = self.re_lineno.match(line) + if match: + lineoffset = int(match.group(1)) + continue + + result.append(line, document.current_source, lineoffset) rst_parser = RSTParser() rst_parser.parse('\n'.join(result), document) |