From 41f2dfcb4913483eaeb6127230a94db3710d562d Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Tue, 3 Dec 2019 14:51:31 -0800 Subject: [PATCH 1/3] Delay import of Sphinx --- numpydoc/docscrape.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index c9829f92..7793f72d 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -11,7 +11,6 @@ import copy import sys -from sphinx.ext.autodoc import ALL def strip_blank_lines(l): "Remove leading and trailing blank lines from a list of lines" @@ -617,6 +616,8 @@ class ClassDoc(NumpyDocString): def __init__(self, cls, doc=None, modulename='', func_doc=FunctionDoc, config={}): + from sphinx.ext.autodoc import ALL + if not inspect.isclass(cls) and cls is not None: raise ValueError("Expected a class or None, but got %r" % cls) self._cls = cls From 75889161f17679c2b4b761ecd24a2d04a2b0eb01 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Tue, 3 Dec 2019 21:44:19 -0800 Subject: [PATCH 2/3] ENH: do not import Sphinx unless it has already been imported --- numpydoc/docscrape.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index 7793f72d..268642ba 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -11,6 +11,10 @@ import copy import sys +if 'sphinx' in sys.modules: + from sphinx.ext.autodoc import ALL +else: + ALL = object() def strip_blank_lines(l): "Remove leading and trailing blank lines from a list of lines" @@ -616,8 +620,6 @@ class ClassDoc(NumpyDocString): def __init__(self, cls, doc=None, modulename='', func_doc=FunctionDoc, config={}): - from sphinx.ext.autodoc import ALL - if not inspect.isclass(cls) and cls is not None: raise ValueError("Expected a class or None, but got %r" % cls) self._cls = cls From 84dfa31c950521b1121285e0d0a42b56948fd080 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Tue, 3 Dec 2019 22:49:44 -0800 Subject: [PATCH 3/3] Delay import of Sphinx --- numpydoc/docscrape.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py index 268642ba..affbb03e 100644 --- a/numpydoc/docscrape.py +++ b/numpydoc/docscrape.py @@ -11,10 +11,6 @@ import copy import sys -if 'sphinx' in sys.modules: - from sphinx.ext.autodoc import ALL -else: - ALL = object() def strip_blank_lines(l): "Remove leading and trailing blank lines from a list of lines" @@ -624,6 +620,11 @@ def __init__(self, cls, doc=None, modulename='', func_doc=FunctionDoc, raise ValueError("Expected a class or None, but got %r" % cls) self._cls = cls + if 'sphinx' in sys.modules: + from sphinx.ext.autodoc import ALL + else: + ALL = object() + self.show_inherited_members = config.get( 'show_inherited_class_members', True)