Re: [PATCH v2] Documentation/sphinx: Fix Directive import error

From: Matthew Wilcox
Date: Fri Mar 02 2018 - 11:34:45 EST


On Fri, Mar 02, 2018 at 04:28:31PM +0100, Takashi Iwai wrote:
> from docutils.parsers.rst import directives
> -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.

> +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'