Documentation/sphinx: Fix Directive import error
Subsystems (2)
PATCH v2 1/1 Documentation/sphinx: Fix Directive import error
The sphinx.util.compat for Directive stuff was deprecated in the recent Sphinx version, and now we get a build error.
Let's import from the new place, docutils.parsers.rst, while keeping the old sphinx.util.compat as fallback.
Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=1083694
---v1->v2: Change the fallback order as Matthew suggested, the new one at first
Documentation/sphinx/kerneldoc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/sphinx/kerneldoc.py +4 -1
@@ -37,7 +37,10 @@ import glob from docutils import nodes, statemachine from docutils.statemachine import ViewList from docutils.parsers.rst import directives -from sphinx.util.compat import Directive +try: + from docutils.parsers.rst import directives, Directive +except ImportError: + from sphinx.util.compat import Directive from sphinx.ext.autodoc import AutodocReporter __version__ = '1.0'
Signature · 6 lines
2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Takashi Iwai
The sphinx.util.compat for Directive stuff was deprecated in the recent Sphinx version, and now we get a build error.
Let's import from the new place,
docutils.parsers.rst, while keeping the old sphinx.util.compat as fallback.Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=1083694
Signed-off-by Takashi Iwai <[email protected]>---
v1->v2: Change the fallback order as Matthew suggested, the new one at first
So this crossed my mind as well... and then I thought it'll probably succeed on older Sphinx, and the fallback is not needed. The question is, are these equal? Can we just import from docutils.parsers.rst?
I'm sorry I don't have the time to find the answers to these questions as well. :(
BR,
Jani.
Quoted 20 lines
Documentation/sphinx/kerneldoc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Documentation/sphinx/kerneldoc.py +4
-1@@ -37,7 +37,10 @@ import glob from docutils import nodes, statemachine from docutils.statemachine import ViewList from docutils.parsers.rst import directives -from sphinx.util.compat import Directive +try: + from docutils.parsers.rst import directives, Directive +except ImportError: + from sphinx.util.compat import Directive from sphinx.ext.autodoc import AutodocReporter __version__ = '1.0'
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Documentation/sphinx/kerneldoc.py import glob · line 41
Quoted 4 lines · Takashi Iwai
from
docutils.parsers.rstimport directivesDocumentation/sphinx/kerneldoc.py +2
-1-from sphinx.util.compat import Directive +try: + from docutils.parsers.rst import directives, Directive
We also don't need 'directives' on this line as it was imported on the previous line.
Documentation/sphinx/kerneldoc.py import glob · line 46
Quoted 5 lines
Documentation/sphinx/kerneldoc.py +2
-0+except ImportError: + from sphinx.util.compat import Directive from sphinx.ext.autodoc import AutodocReporter __version__ = '1.0'
Here's what I tested on Debian:
+++ b/Documentation/sphinx/kerneldoc.py
@@ -37,7 +37,10 @@ import glob
from docutils import nodes, statemachine
from docutils.statemachine import ViewList
from docutils.parsers.rst import directives
-from sphinx.util.compat import Directive
+try:
+ from docutils.parsers.rst import Directive
+except ImportError:
+ from sphinx.util.compat import Directive
from sphinx.ext.autodoc import AutodocReporter
__version__ = '1.0'
Quoted 7 lines · Jani Nikula
Quoted 6 lines · Takashi Iwai
The sphinx.util.compat for Directive stuff was deprecated in the recent Sphinx version, and now we get a build error.
Let's import from the new place,
docutils.parsers.rst, while keeping the old sphinx.util.compat as fallback.
Quoted 8 lines
Quoted 4 lines
Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=1083694
Signed-off-by Takashi Iwai <[email protected]>---
v1->v2: Change the fallback order as Matthew suggested, the new one at firstSo this crossed my mind as well... and then I thought it'll probably succeed on older Sphinx, and the fallback is not needed. The question is, are these equal? Can we just import from
docutils.parsers.rst?
I found a github page which implies that docutils.parsers.rst.Directive was added 12 years ago (!) so we're probably safe to rely on it:
https://github.com/docutils-mirror/docutils/commit/9649abee47b4ce4db51be1d90fcb1fb500fa78b3
Again, I'm no pythonista, so I may have muddled this.
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 17 lines · Matthew Wilcox
Quoted 7 lines · Jani Nikula
Quoted 6 lines · Takashi Iwai
The sphinx.util.compat for Directive stuff was deprecated in the recent Sphinx version, and now we get a build error.
Let's import from the new place,
docutils.parsers.rst, while keeping the old sphinx.util.compat as fallback.Quoted 8 lines
Quoted 4 lines
Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=1083694
Signed-off-by Takashi Iwai <[email protected]>---
v1->v2: Change the fallback order as Matthew suggested, the new one at firstSo this crossed my mind as well... and then I thought it'll probably succeed on older Sphinx, and the fallback is not needed. The question is, are these equal? Can we just import from
docutils.parsers.rst?
Quoted 6 lines
I found a github page which implies that docutils.parsers.rst.Directive was added 12 years ago (!) so we're probably safe to rely on it:
https://github.com/docutils-mirror/docutils/commit/9649abee47b4ce4db51be1d90fcb1fb500fa78b3
Again, I'm no pythonista, so I may have muddled this.
I spent some time delving through the Sphinx codebase. The compat version was added so you could use Directive with docutils 0.4 onwards. docutils 0.5 onwards has Directive. So as long as we're comfortable mandating docutils from 2009, we're fine ;-)
PATCH v3 1/1 Documentation/sphinx: Fix Directive import error
In reply to Takashi IwaiFrom: Matthew Wilcox <[email protected]>
Sphinx 1.7 removed sphinx.util.compat.Directive so people who have upgraded cannot build the documentation. Switch to docutils.parsers.rst.Directive which has been available since docutils 0.5 released in 2009.
Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=1083694
Documentation/sphinx/kerneldoc.py +1 -2
@@ -36,8 +36,7 @@ import glob from docutils import nodes, statemachine from docutils.statemachine import ViewList -from docutils.parsers.rst import directives -from sphinx.util.compat import Directive +from docutils.parsers.rst import directives, Directive from sphinx.ext.autodoc import AutodocReporter __version__ = '1.0'
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Matthew Wilcox
From: Matthew Wilcox <[email protected]>
Sphinx 1.7 removed sphinx.util.compat.Directive so people who have upgraded cannot build the documentation. Switch to docutils.parsers.rst.Directive which has been available since docutils 0.5 released in 2009.
Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=1083694
Co-developed-by Takashi Iwai <[email protected]>Signed-off-by Matthew Wilcox <[email protected]>
I think this is the best approach.
FWIW,
Quoted 15 lines
Documentation/sphinx/kerneldoc.py +1
-2@@ -36,8 +36,7 @@ import glob from docutils import nodes, statemachine from docutils.statemachine import ViewList -from docutils.parsers.rst import directives -from sphinx.util.compat import Directive +from docutils.parsers.rst import directives, Directive from sphinx.ext.autodoc import AutodocReporter __version__ = '1.0'
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Jonathan Corbet
maintainerQuoted 8 lines · On Fri, 2 Mar 2018 10:40:14 -0800 Matthew Wilcox <[email protected]> wrote:
Sphinx 1.7 removed sphinx.util.compat.Directive so people who have upgraded cannot build the documentation. Switch to docutils.parsers.rst.Directive which has been available since docutils 0.5 released in 2009.
Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=1083694
Co-developed-by Takashi Iwai <[email protected]>Signed-off-by Matthew Wilcox <[email protected]>
FWIW, I've *finally* gotten a chance to test this with a few sphinx versions; it works just fine, of course. Will get it upstream shortly.
Thanks,
jon