* [PATCH] docs/sphinx: Explicitly convert Sphinx paths to str
@ 2023-09-10 4:08 Oliver Faso
2023-09-10 4:18 ` Matthew Wilcox
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Oliver Faso @ 2023-09-10 4:08 UTC (permalink / raw)
To: Jonathan Corbet; +Cc: Oliver Faso, linux-doc, linux-kernel
Sphinx 7.2+ is switching to using pathlib.Path
instead of str to represent paths. This fixes the
current deprecation warnings and eventual breakage.
This conversion will be a no-op when using older
Sphinx versions.
Signed-off-by: Oliver Faso <erer1243@gmail.com>
---
Documentation/sphinx/kerneldoc.py | 2 +-
Documentation/sphinx/kfigure.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerneldoc.py
index 9395892c7ba3..d26155990ec3 100644
--- a/Documentation/sphinx/kerneldoc.py
+++ b/Documentation/sphinx/kerneldoc.py
@@ -138,7 +138,7 @@ 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 = str(env.srcdir) + "/" + env.docname + ":" + str(self.lineno)
result.append(line, doc + ": " + filename, lineoffset)
lineoffset += 1
diff --git a/Documentation/sphinx/kfigure.py b/Documentation/sphinx/kfigure.py
index cefdbb7e7523..13e885bbd499 100644
--- a/Documentation/sphinx/kfigure.py
+++ b/Documentation/sphinx/kfigure.py
@@ -309,7 +309,7 @@ def convert_image(img_node, translator, src_fname=None):
if dst_fname:
# the builder needs not to copy one more time, so pop it if exists.
translator.builder.images.pop(img_node['uri'], None)
- _name = dst_fname[len(translator.builder.outdir) + 1:]
+ _name = dst_fname[len(str(translator.builder.outdir)) + 1:]
if isNewer(dst_fname, src_fname):
kernellog.verbose(app,
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] docs/sphinx: Explicitly convert Sphinx paths to str
2023-09-10 4:08 [PATCH] docs/sphinx: Explicitly convert Sphinx paths to str Oliver Faso
@ 2023-09-10 4:18 ` Matthew Wilcox
2023-09-10 4:37 ` Oliver F
2023-09-27 14:09 ` Akira Yokosawa
2023-10-03 15:57 ` Jonathan Corbet
2 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2023-09-10 4:18 UTC (permalink / raw)
To: Oliver Faso; +Cc: Jonathan Corbet, linux-doc, linux-kernel
On Sun, Sep 10, 2023 at 12:08:06AM -0400, Oliver Faso wrote:
> else:
> - doc = env.srcdir + "/" + env.docname + ":" + str(self.lineno)
> + doc = str(env.srcdir) + "/" + env.docname + ":" + str(self.lineno)
Would we be better off doing the path manipulation in Path, then converting
to string? ie:
doc = str(env.srcdir / env.docname) + ":" + str(self.lineno)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] docs/sphinx: Explicitly convert Sphinx paths to str
2023-09-10 4:18 ` Matthew Wilcox
@ 2023-09-10 4:37 ` Oliver F
0 siblings, 0 replies; 5+ messages in thread
From: Oliver F @ 2023-09-10 4:37 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: Jonathan Corbet, linux-doc, linux-kernel
On Sun, Sep 10, 2023 at 12:19 AM Matthew Wilcox <willy@infradead.org> wrote:
>
> On Sun, Sep 10, 2023 at 12:08:06AM -0400, Oliver Faso wrote:
> > else:
> > - doc = env.srcdir + "/" + env.docname + ":" + str(self.lineno)
> > + doc = str(env.srcdir) + "/" + env.docname + ":" + str(self.lineno)
>
> Would we be better off doing the path manipulation in Path, then converting
> to string? ie:
>
> doc = str(env.srcdir / env.docname) + ":" + str(self.lineno)
>
That would be incompatible with earlier Sphinx versions, which most
people are probably using.
The benefits would be supporting non-'/' separators, and invalid uft8 in paths.
But, I think those things don't matter here.
(sorry Matthew for double mail, I hit the wrong reply button)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] docs/sphinx: Explicitly convert Sphinx paths to str
2023-09-10 4:08 [PATCH] docs/sphinx: Explicitly convert Sphinx paths to str Oliver Faso
2023-09-10 4:18 ` Matthew Wilcox
@ 2023-09-27 14:09 ` Akira Yokosawa
2023-10-03 15:57 ` Jonathan Corbet
2 siblings, 0 replies; 5+ messages in thread
From: Akira Yokosawa @ 2023-09-27 14:09 UTC (permalink / raw)
To: Oliver Faso, Jonathan Corbet; +Cc: linux-doc, linux-kernel, Akira Yokosawa
Hi,
On Sun, 10 Sep 2023 00:08:06 -0400, Oliver Faso wrote:
> Sphinx 7.2+ is switching to using pathlib.Path
> instead of str to represent paths. This fixes the
> current deprecation warnings and eventual breakage.
> This conversion will be a no-op when using older
> Sphinx versions.
>
> Signed-off-by: Oliver Faso <erer1243@gmail.com>
Belatedly tested against Sphinx versions 2.4.5, 4.2.0, 5.3.0,
and 7.2.6 (latest).
Tested-by: Akira Yokosawa <akiyks@gmail.com>
HTH, Akira
> ---
> Documentation/sphinx/kerneldoc.py | 2 +-
> Documentation/sphinx/kfigure.py | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerneldoc.py
> index 9395892c7ba3..d26155990ec3 100644
> --- a/Documentation/sphinx/kerneldoc.py
> +++ b/Documentation/sphinx/kerneldoc.py
> @@ -138,7 +138,7 @@ 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 = str(env.srcdir) + "/" + env.docname + ":" + str(self.lineno)
> result.append(line, doc + ": " + filename, lineoffset)
> lineoffset += 1
>
> diff --git a/Documentation/sphinx/kfigure.py b/Documentation/sphinx/kfigure.py
> index cefdbb7e7523..13e885bbd499 100644
> --- a/Documentation/sphinx/kfigure.py
> +++ b/Documentation/sphinx/kfigure.py
> @@ -309,7 +309,7 @@ def convert_image(img_node, translator, src_fname=None):
> if dst_fname:
> # the builder needs not to copy one more time, so pop it if exists.
> translator.builder.images.pop(img_node['uri'], None)
> - _name = dst_fname[len(translator.builder.outdir) + 1:]
> + _name = dst_fname[len(str(translator.builder.outdir)) + 1:]
>
> if isNewer(dst_fname, src_fname):
> kernellog.verbose(app,
> --
> 2.42.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] docs/sphinx: Explicitly convert Sphinx paths to str
2023-09-10 4:08 [PATCH] docs/sphinx: Explicitly convert Sphinx paths to str Oliver Faso
2023-09-10 4:18 ` Matthew Wilcox
2023-09-27 14:09 ` Akira Yokosawa
@ 2023-10-03 15:57 ` Jonathan Corbet
2 siblings, 0 replies; 5+ messages in thread
From: Jonathan Corbet @ 2023-10-03 15:57 UTC (permalink / raw)
To: Oliver Faso; +Cc: Oliver Faso, linux-doc, linux-kernel
Oliver Faso <erer1243@gmail.com> writes:
> Sphinx 7.2+ is switching to using pathlib.Path
> instead of str to represent paths. This fixes the
> current deprecation warnings and eventual breakage.
> This conversion will be a no-op when using older
> Sphinx versions.
>
> Signed-off-by: Oliver Faso <erer1243@gmail.com>
> ---
> Documentation/sphinx/kerneldoc.py | 2 +-
> Documentation/sphinx/kfigure.py | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
I've applied this, thanks.
jon
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-03 15:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-10 4:08 [PATCH] docs/sphinx: Explicitly convert Sphinx paths to str Oliver Faso
2023-09-10 4:18 ` Matthew Wilcox
2023-09-10 4:37 ` Oliver F
2023-09-27 14:09 ` Akira Yokosawa
2023-10-03 15:57 ` Jonathan Corbet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).