|
19 | 19 | ModuleAnalyzer, bool_option, AttributeDocumenter, DataDocumenter, Options, |
20 | 20 | prepare_docstring) |
21 | 21 | import sphinx.ext.autodoc as ad |
22 | | -from sphinx.ext.autosummary import Autosummary, ViewList, mangle_signature |
| 22 | +from sphinx.ext.autosummary import Autosummary, mangle_signature |
23 | 23 | from docutils import nodes |
| 24 | +from docutils.statemachine import ViewList |
24 | 25 |
|
25 | 26 | if sphinx.__version__ >= '1.7': |
26 | | - from sphinx.ext.autodoc import Signature, AutodocRegistry, get_documenters |
| 27 | + from sphinx.ext.autodoc import Signature, get_documenters |
27 | 28 | from sphinx.ext.autodoc.directive import ( |
28 | 29 | AutodocDirective, AUTODOC_DEFAULT_OPTIONS, DocumenterBridge, |
29 | 30 | process_documenter_options) |
|
36 | 37 | from sphinx.util import force_decode |
37 | 38 | else: |
38 | 39 | from sphinx.ext.autodoc import force_decode |
39 | | - |
| 40 | + |
| 41 | + |
40 | 42 | try: |
41 | 43 | from cyordereddict import OrderedDict |
42 | 44 | except ImportError: |
|
53 | 55 | __author__ = "Philipp Sommer" |
54 | 56 |
|
55 | 57 |
|
56 | | -sphinx_version = list(map(float, re.findall('\d+', sphinx.__version__)[:3])) |
| 58 | +sphinx_version = list(map(float, re.findall(r'\d+', sphinx.__version__)[:3])) |
57 | 59 |
|
58 | 60 |
|
59 | 61 | class AutosummaryDocumenter(object): |
@@ -416,12 +418,13 @@ def run(self): |
416 | 418 | doc_nodes = AutodocDirective.run(self) |
417 | 419 | if 'autosummary' not in self.options: |
418 | 420 | return doc_nodes |
419 | | - self.warnings = [] |
420 | 421 | try: |
421 | 422 | self.env = self.state.document.settings.env |
422 | 423 | except AttributeError: |
423 | 424 | pass # is set automatically with sphinx >= 1.8.0 |
424 | | - self.result = ViewList() |
| 425 | + if sphinx_version < [2, 0]: |
| 426 | + self.warning = [] |
| 427 | + self.result = ViewList() |
425 | 428 | documenter = self.autosummary_documenter |
426 | 429 | grouped_documenters = documenter.get_grouped_documenters() |
427 | 430 | summ_nodes = self.autosumm_nodes(documenter, grouped_documenters) |
|
0 commit comments