Documentation: Use relative source filenames in ABI documentation
authorBen Hutchings <benh@debian.org>
Sun, 15 Sep 2024 22:07:04 +0000 (00:07 +0200)
committerSalvatore Bonaccorso <carnil@debian.org>
Tue, 12 Aug 2025 03:28:04 +0000 (05:28 +0200)
Currently the ABI documentation files contain absolute source
filenames, which makes them unreproducible if the build directory can
vary.

Remove the source base directory ($srctree) from the source filenames
shown in the documentation.

Signed-off-by: Ben Hutchings <benh@debian.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name documentation-use-relative-source-paths-in-abi-documentation.patch

Documentation/sphinx/kernel_abi.py

index 5911bd0d7965713a4905db331818c57d23dadb73..b52b4c8842c9db6a256f5fdffffd174b619f04b1 100644 (file)
@@ -103,6 +103,7 @@ class KernelCmd(Directive):
             lines = code_block + "\n\n"
 
         line_regex = re.compile(r"^\.\. LINENO (\S+)\#([0-9]+)$")
+        srctree = os.path.abspath(os.environ["srctree"])
         ln = 0
         n = 0
         f = fname
@@ -127,7 +128,7 @@ class KernelCmd(Directive):
                 # sphinx counts lines from 0
                 ln = int(match.group(2)) - 1
             else:
-                content.append(line, f, ln)
+                content.append(line, os.path.relpath(f, srctree), ln)
 
         kernellog.info(self.state.document.settings.env.app, "%s: parsed %i lines" % (fname, n))