summaryrefslogtreecommitdiff
path: root/Documentation/sphinx/kernel_include.py
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2025-08-22 17:19:32 +0300
committerJonathan Corbet <corbet@lwn.net>2025-08-30 00:54:43 +0300
commit4aa578f9c087d58d841e3dfbde1bf57483d9e696 (patch)
treee58dc0221f61b53316f55106f2afd845406bb645 /Documentation/sphinx/kernel_include.py
parent01dba1680cb4047d4f6e057276f805f93b7eea00 (diff)
downloadlinux-4aa578f9c087d58d841e3dfbde1bf57483d9e696.tar.xz
docs: kernel_include.py: remove line numbers from parsed-literal
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
Diffstat (limited to 'Documentation/sphinx/kernel_include.py')
-rwxr-xr-xDocumentation/sphinx/kernel_include.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/Documentation/sphinx/kernel_include.py b/Documentation/sphinx/kernel_include.py
index fd4887f80577..3a1753486319 100755
--- a/Documentation/sphinx/kernel_include.py
+++ b/Documentation/sphinx/kernel_include.py
@@ -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)