]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
docs: kernel_include.py: remove line numbers from parsed-literal
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fri, 22 Aug 2025 14:19:32 +0000 (16:19 +0200)
committerJonathan Corbet <corbet@lwn.net>
Fri, 29 Aug 2025 21:54:43 +0000 (15:54 -0600)
When parsed-literal directive is added to rawtext, while cross
references will be properly displayed, Sphinx will ignore
line numbers. So, it is not worth adding them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/b484fe5fcbf6e5217f112f205fbf54f0bbc3dcca.1755872208.git.mchehab+huawei@kernel.org
Documentation/sphinx/kernel_include.py

index fd4887f80577eaaa5bab3db841143048afbbb41e..3a1753486319c4e845d31cc5ce909051cde29dd3 100755 (executable)
@@ -171,13 +171,24 @@ class KernelInclude(Include):
         if 'warn-broken' in self.options:
             env._xref_files.add(path)
 
-        if "toc" in self.options:
-            rawtext = parser.gen_toc()
-        else:
+        if "toc" not in self.options:
+
             rawtext = ".. parsed-literal::\n\n" + parser.gen_output()
             self.apply_range(rawtext)
 
-        title = os.path.basename(path)
+            include_lines = statemachine.string2lines(rawtext, tab_width,
+                                                      convert_whitespace=True)
+
+            # Sphinx always blame the ".. <directive>", so placing
+            # line numbers here won't make any difference
+
+            self.state_machine.insert_input(include_lines, path)
+            return []
+
+        # TOC output is a ReST file, not a literal. So, we can add line
+        # numbers
+
+        rawtext = parser.gen_toc()
 
         include_lines = statemachine.string2lines(rawtext, tab_width,
                                                   convert_whitespace=True)