Skip to content

Commit 87db9a1

Browse files
committed
Compatibility fixes for sphinx 1.8.0
1 parent 255b630 commit 87db9a1

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

autodocsumm/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,10 @@ def run(self):
412412
if 'autosummary' not in self.options:
413413
return doc_nodes
414414
self.warnings = []
415-
self.env = self.state.document.settings.env
415+
try:
416+
self.env = self.state.document.settings.env
417+
except AttributeError:
418+
pass # is set automatically with sphinx >= 1.8.0
416419
self.result = ViewList()
417420
documenter = self.autosummary_documenter
418421
grouped_documenters = documenter.get_grouped_documenters()

tests/test_autodocsumm.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,21 @@ def in_between(full, sub, s0, *others):
1919
return full.index(sub) > i0 and full.index(sub) < last
2020

2121

22+
def get_html(app, fname):
23+
try:
24+
return (app.outdir / fname).read_text()
25+
except TypeError:
26+
with open(app.outdir + '/' + fname) as f:
27+
return f.read()
28+
29+
2230
class TestAutosummaryDocumenter(unittest.TestCase):
2331

2432
@with_app(buildername='html', srcdir=sphinx_supp,
2533
copy_srcdir_to_tmpdir=True)
2634
def test_module(self, app, status, warning):
2735
app.build()
28-
html = (app.outdir / 'test_module.html').read_text()
36+
html = get_html(app, 'test_module.html')
2937
self.assertIn('<span class="pre">TestClass</span>', html)
3038
self.assertIn('<span class="pre">test_func</span>', html)
3139
self.assertIn('<span class="pre">test_method</span>', html)
@@ -49,7 +57,7 @@ def test_module(self, app, status, warning):
4957
copy_srcdir_to_tmpdir=True)
5058
def test_module_with_title(self, app, status, warning):
5159
app.build()
52-
html = (app.outdir / 'test_module_title.html').read_text()
60+
html = get_html(app, 'test_module_title.html')
5361
self.assertIn('<span class="pre">TestClass</span>', html)
5462
self.assertIn('<span class="pre">test_func</span>', html)
5563
self.assertIn('<span class="pre">test_method</span>', html)
@@ -73,7 +81,7 @@ def test_module_with_title(self, app, status, warning):
7381
copy_srcdir_to_tmpdir=True)
7482
def test_class(self, app, status, warning):
7583
app.build()
76-
html = (app.outdir / 'test_class.html').read_text()
84+
html = get_html(app, '/test_class.html')
7785
self.assertIn('<span class="pre">test_method</span>', html)
7886
self.assertIn('<span class="pre">test_attr</span>', html)
7987

0 commit comments

Comments
 (0)