Skip to contentSkip to conversation

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

PATCH In review Claudio Cambra 3 participants 4 messages Sep 24, 2023 – Oct 3, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docs: Fix Sphinx 8 warning caused by paths represented with strings

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.

---
 Documentation/sphinx/kerneldoc.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/sphinx/kerneldoc.py +2 -1
index 9395892c7ba3..e2c835e10dba 100644
@@ -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
 
Signature · 1 line
2.42.0
reviewer
#1 lore raw

Hi,

Quoted 18 lines · Claudio Cambra

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.

---
 Documentation/sphinx/kerneldoc.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/sphinx/kerneldoc.py +0 -0
index 9395892c7ba3..e2c835e10dba 100644

Documentation/sphinx/kerneldoc.py class KernelDocDirective(Directive): · line 145

Quoted 9 lines
Documentation/sphinx/kerneldoc.py +2 -1
@@ -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
 

This patch should be sent to the [email protected] mailing list, with the Documentation maintainer copied on the patch.

We also have this similar patch to consider:
https://lore.kernel.org/linux-doc/[email protected]/

Thanks.

Signature · 1 line
~Randy
#2 lore raw

Hi,

Quoted 33 lines · Randy Dunlap

Hi,

Quoted 18 lines · Claudio Cambra

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.

---
  Documentation/sphinx/kerneldoc.py | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/sphinx/kerneldoc.py +0 -0
index 9395892c7ba3..e2c835e10dba 100644

Documentation/sphinx/kerneldoc.py class KernelDocDirective(Directive): · line 145

Quoted 9 lines
Documentation/sphinx/kerneldoc.py +2 -1
@@ -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
 

This patch should be sent to the [email protected] mailing list, with the Documentation maintainer copied on the patch.

Quoted 4 lines

We also have this similar patch to consider:

   https://lore.kernel.org/linux-doc/[email protected]/

Thanks.

Thanks Randy, will keep in mind for future patches

Cheers,

Claudio

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

maintainer
#3 lore raw
In reply to Randy Dunlap
Quoted 34 lines · Randy Dunlap

Hi,

Quoted 18 lines · Claudio Cambra

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.

---
 Documentation/sphinx/kerneldoc.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/sphinx/kerneldoc.py +0 -0
index 9395892c7ba3..e2c835e10dba 100644

Documentation/sphinx/kerneldoc.py class KernelDocDirective(Directive): · line 145

Quoted 9 lines
Documentation/sphinx/kerneldoc.py +2 -1
@@ -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
 

This patch should be sent to the [email protected] mailing list, with the Documentation maintainer copied on the patch.

Quoted 2 lines

We also have this similar patch to consider:
https://lore.kernel.org/linux-doc/[email protected]/

I have, in fact, applied that other patch.

Thanks,

jon
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees