Thread (4 messages) 4 messages, 3 authors, 2023-10-03
STALE969d

[PATCH] docs: Fix Sphinx 8 warning caused by paths represented with strings

From: Claudio Cambra <hidden>
Date: 2023-09-24 18:41:37
Also in: lkml
Subsystem: documentation, documentation scripts, the rest · Maintainers: Jonathan Corbet, Mauro Carvalho Chehab, Linus Torvalds

Running "make htmldocs" generates several lines of this warning:

Documentation/sphinx/kerneldoc.py:141: RemovedInSphinx80Warning: Sphinx 8 will drop support for representing paths as strings. Use "pathlib.Path" or "os.fspath" instead.
  doc = (env.srcdir + "/" + env.docname + ":" + str(self.lineno))

Making "doc" an fspath type and creating a new variable with the
appended colon and lineno fixes this warning.

Signed-off-by: Claudio Cambra <redacted>
---
 Documentation/sphinx/kerneldoc.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerneldoc.py
index 9395892c7ba3..e2c835e10dba 100644
--- a/Documentation/sphinx/kerneldoc.py
+++ b/Documentation/sphinx/kerneldoc.py
@@ -138,7 +138,8 @@ class KernelDocDirective(Directive):
                     lineoffset = int(match.group(1)) - 1
                     # we must eat our comments since the upset the markup
                 else:
-                    doc = env.srcdir + "/" + env.docname + ":" + str(self.lineno)
+                    doc = os.path.join(env.srcdir, env.docname)
+                    doc_with_line = (doc + ":" + str(self.lineno))
                     result.append(line, doc + ": " + filename, lineoffset)
                     lineoffset += 1
 
-- 
2.42.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help