|
17 | 17 | from sphinx.ext.autodoc import ( |
18 | 18 | ClassDocumenter, ModuleDocumenter, ALL, PycodeError, |
19 | 19 | ModuleAnalyzer, bool_option, AttributeDocumenter, DataDocumenter, Options, |
20 | | - force_decode, prepare_docstring) |
| 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) |
|
32 | 33 | getargspec, formatargspec, AutoDirective as AutodocDirective, |
33 | 34 | AutoDirective as AutodocRegistry) |
34 | 35 |
|
| 36 | +if sphinx.__version__ >= '2.0': |
| 37 | + from sphinx.util import force_decode |
| 38 | +else: |
| 39 | + from sphinx.ext.autodoc import force_decode |
| 40 | + |
| 41 | + |
35 | 42 | try: |
36 | 43 | from cyordereddict import OrderedDict |
37 | 44 | except ImportError: |
|
48 | 55 | __author__ = "Philipp Sommer" |
49 | 56 |
|
50 | 57 |
|
51 | | -sphinx_version = list(map(float, re.findall('\d+', sphinx.__version__)[:3])) |
| 58 | +sphinx_version = list(map(float, re.findall(r'\d+', sphinx.__version__)[:3])) |
52 | 59 |
|
53 | 60 |
|
54 | 61 | class AutosummaryDocumenter(object): |
@@ -411,12 +418,13 @@ def run(self): |
411 | 418 | doc_nodes = AutodocDirective.run(self) |
412 | 419 | if 'autosummary' not in self.options: |
413 | 420 | return doc_nodes |
414 | | - self.warnings = [] |
415 | 421 | try: |
416 | 422 | self.env = self.state.document.settings.env |
417 | 423 | except AttributeError: |
418 | 424 | pass # is set automatically with sphinx >= 1.8.0 |
419 | | - self.result = ViewList() |
| 425 | + if sphinx_version < [2, 0]: |
| 426 | + self.warnings = [] |
| 427 | + self.result = ViewList() |
420 | 428 | documenter = self.autosummary_documenter |
421 | 429 | grouped_documenters = documenter.get_grouped_documenters() |
422 | 430 | summ_nodes = self.autosumm_nodes(documenter, grouped_documenters) |
|
0 commit comments