mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7661 from mondeja/7552
Fix autosummary directive wrong processing for invalid modules.
This commit is contained in:
commit
b8ecec83d4
@ -302,8 +302,7 @@ class Autosummary(SphinxDirective):
|
|||||||
with mock(self.config.autosummary_mock_imports):
|
with mock(self.config.autosummary_mock_imports):
|
||||||
real_name, obj, parent, modname = import_by_name(name, prefixes=prefixes)
|
real_name, obj, parent, modname = import_by_name(name, prefixes=prefixes)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logger.warning(__('failed to import %s'), name)
|
logger.warning(__('autosummary: failed to import %s'), name)
|
||||||
items.append((name, '', '', name))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.bridge.result = StringList() # initialize for each documenter
|
self.bridge.result = StringList() # initialize for each documenter
|
||||||
|
@ -203,17 +203,16 @@ def test_autosummary_generate(app, status, warning):
|
|||||||
[autosummary_table, nodes.table, nodes.tgroup, (nodes.colspec,
|
[autosummary_table, nodes.table, nodes.tgroup, (nodes.colspec,
|
||||||
nodes.colspec,
|
nodes.colspec,
|
||||||
[nodes.tbody, (nodes.row,
|
[nodes.tbody, (nodes.row,
|
||||||
nodes.row,
|
|
||||||
nodes.row,
|
nodes.row,
|
||||||
nodes.row,
|
nodes.row,
|
||||||
nodes.row)])])
|
nodes.row)])])
|
||||||
assert_node(doctree[4][0], addnodes.toctree, caption="An autosummary")
|
assert_node(doctree[4][0], addnodes.toctree, caption="An autosummary")
|
||||||
|
|
||||||
|
assert len(doctree[3][0][0][2]) == 4
|
||||||
assert doctree[3][0][0][2][0].astext() == 'autosummary_dummy_module\n\n'
|
assert doctree[3][0][0][2][0].astext() == 'autosummary_dummy_module\n\n'
|
||||||
assert doctree[3][0][0][2][1].astext() == 'autosummary_dummy_module.Foo()\n\n'
|
assert doctree[3][0][0][2][1].astext() == 'autosummary_dummy_module.Foo()\n\n'
|
||||||
assert doctree[3][0][0][2][2].astext() == 'autosummary_dummy_module.Foo.Bar\n\n'
|
assert doctree[3][0][0][2][2].astext() == 'autosummary_dummy_module.Foo.Bar\n\n'
|
||||||
assert doctree[3][0][0][2][3].astext() == 'autosummary_dummy_module.bar(x[, y])\n\n'
|
assert doctree[3][0][0][2][3].astext() == 'autosummary_dummy_module.bar(x[, y])\n\n'
|
||||||
assert doctree[3][0][0][2][4].astext() == 'autosummary_importfail\n\n'
|
|
||||||
|
|
||||||
module = (app.srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text()
|
module = (app.srcdir / 'generated' / 'autosummary_dummy_module.rst').read_text()
|
||||||
assert (' .. autosummary::\n'
|
assert (' .. autosummary::\n'
|
||||||
@ -397,7 +396,7 @@ def test_autosummary_template(app):
|
|||||||
confoverrides={'autosummary_generate': []})
|
confoverrides={'autosummary_generate': []})
|
||||||
def test_empty_autosummary_generate(app, status, warning):
|
def test_empty_autosummary_generate(app, status, warning):
|
||||||
app.build()
|
app.build()
|
||||||
assert ("WARNING: autosummary: stub file not found 'autosummary_importfail'"
|
assert ("WARNING: autosummary: failed to import autosummary_importfail"
|
||||||
in warning.getvalue())
|
in warning.getvalue())
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user