Skip to content

Commit c0a03fc

Browse files
authored
Merge pull request #1 from dburkhardt/patch-2
Compatibility fixes for sphinx 2.0
2 parents de87cf3 + 24239e4 commit c0a03fc

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

autodocsumm/__init__.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
from sphinx.ext.autodoc import (
1818
ClassDocumenter, ModuleDocumenter, ALL, PycodeError,
1919
ModuleAnalyzer, bool_option, AttributeDocumenter, DataDocumenter, Options,
20-
force_decode, prepare_docstring)
20+
prepare_docstring)
2121
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
2323
from docutils import nodes
24+
from docutils.statemachine import ViewList
2425

2526
if sphinx.__version__ >= '1.7':
26-
from sphinx.ext.autodoc import Signature, AutodocRegistry, get_documenters
27+
from sphinx.ext.autodoc import Signature, get_documenters
2728
from sphinx.ext.autodoc.directive import (
2829
AutodocDirective, AUTODOC_DEFAULT_OPTIONS, DocumenterBridge,
2930
process_documenter_options)
@@ -32,6 +33,12 @@
3233
getargspec, formatargspec, AutoDirective as AutodocDirective,
3334
AutoDirective as AutodocRegistry)
3435

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+
3542
try:
3643
from cyordereddict import OrderedDict
3744
except ImportError:
@@ -48,7 +55,7 @@
4855
__author__ = "Philipp Sommer"
4956

5057

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]))
5259

5360

5461
class AutosummaryDocumenter(object):
@@ -411,12 +418,13 @@ def run(self):
411418
doc_nodes = AutodocDirective.run(self)
412419
if 'autosummary' not in self.options:
413420
return doc_nodes
414-
self.warnings = []
415421
try:
416422
self.env = self.state.document.settings.env
417423
except AttributeError:
418424
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()
420428
documenter = self.autosummary_documenter
421429
grouped_documenters = documenter.get_grouped_documenters()
422430
summ_nodes = self.autosumm_nodes(documenter, grouped_documenters)

tests/sphinx_supp/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# -*- coding: utf-8 -*-
2+
import sys
3+
sys.path.insert(0, '.')
24

35
master_doc = 'index'
46

0 commit comments

Comments
 (0)