Skip to content

Commit affba3d

Browse files
committed
several compatibility fixes for sphinx 3.5
1 parent 8ac0556 commit affba3d

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

autodocsumm/__init__.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from sphinx.ext.autodoc import (
2222
ClassDocumenter, ModuleDocumenter, ALL, PycodeError,
23-
ModuleAnalyzer, bool_option, AttributeDocumenter, DataDocumenter, Options,
23+
ModuleAnalyzer, AttributeDocumenter, DataDocumenter, Options,
2424
prepare_docstring)
2525
import sphinx.ext.autodoc as ad
2626

@@ -85,6 +85,10 @@ def list_option(option):
8585
return [s.strip() for s in option.split(";;")]
8686

8787

88+
def bool_option(*args):
89+
return "True"
90+
91+
8892
class AutosummaryDocumenter(object):
8993
"""Abstract class for for extending Documenter methods
9094
@@ -230,7 +234,10 @@ def get_grouped_documenters(self, all_members=False):
230234

231235
def add_autosummary(self):
232236
"""Add the autosammary table of this documenter."""
233-
if self.options.autosummary:
237+
if (
238+
self.options.get("autosummary")
239+
and not self.options.get("no-autosummary")
240+
):
234241

235242
grouped_documenters = self.get_grouped_documenters()
236243

@@ -297,7 +304,7 @@ def add_content(self, *args, **kwargs):
297304
self.add_autosummary()
298305

299306
if self.options.autosummary_no_nesting:
300-
self.options.autosummary = False
307+
self.options["no-autosummary"] = "True"
301308

302309

303310
class AutoSummClassDocumenter(ClassDocumenter, AutosummaryDocumenter):
@@ -524,10 +531,10 @@ def run(self):
524531
objtype = self.name[4:-4] # strip prefix (auto-) and suffix (-summ).
525532
doccls = self.env.app.registry.documenters[objtype]
526533

527-
self.options['autosummary-force-inline'] = True
528-
self.options['autosummary'] = True
534+
self.options['autosummary-force-inline'] = "True"
535+
self.options['autosummary'] = "True"
529536
if 'no-members' not in self.options:
530-
self.options['members'] = True
537+
self.options['members'] = ""
531538

532539
# process the options with the selected documenter's option_spec
533540
try:

tests/sphinx_supp/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
'dummy.large_data', 'dummy.TestClass.small_data',
2121
'dummy_title.large_data', 'dummy_title.TestClass.small_data']
2222

23+
autodoc_typehints = "description"
24+
2325
autodata_content = 'both'
2426

2527

tests/test_autodocsumm.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,27 @@ def test_module(self, app, status, warning):
5050
self.assertIn('<span class="pre">small_data</span>', html)
5151

5252
self.assertNotIn('Should be skipped', html)
53-
self.assertIn('Should be included', html)
53+
try:
54+
self.assertIn('Should be included', html)
55+
except AssertionError: # sphinx>=3.5
56+
self.assertIn(
57+
'<span class="pre">\'Should</span> '
58+
'<span class="pre">be</span> '
59+
'<span class="pre">included\'</span>',
60+
html
61+
)
5462

5563
self.assertNotIn('Should also be skipped', html)
56-
self.assertIn('Should also be included', html)
64+
try:
65+
self.assertIn('Should also be included', html)
66+
except AssertionError: # sphinx>=3.5
67+
self.assertIn(
68+
'<span class="pre">\'Should</span> '
69+
'<span class="pre">also</span> '
70+
'<span class="pre">be</span> '
71+
'<span class="pre">included\'</span>',
72+
html
73+
)
5774

5875
@with_app(buildername='html', srcdir=sphinx_supp,
5976
copy_srcdir_to_tmpdir=True)
@@ -146,7 +163,15 @@ def test_class(self, app, status, warning):
146163
self.assertIn('<span class="pre">small_data</span>', html)
147164

148165
self.assertNotIn('Should be skipped', html)
149-
self.assertIn('Should be included', html)
166+
try:
167+
self.assertIn('Should be included', html)
168+
except AssertionError: # sphinx>=3.5
169+
self.assertIn(
170+
'<span class="pre">\'Should</span> '
171+
'<span class="pre">be</span> '
172+
'<span class="pre">included\'</span>',
173+
html
174+
)
150175

151176
self.assertIn('DummySection', html)
152177
self.assertTrue(in_between(

0 commit comments

Comments
 (0)