mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Create a new type for the current document's environment state (#13151)
This commit is contained in:
@@ -22,7 +22,8 @@ def do_autodoc(
|
||||
options: dict[str, Any] | None = None,
|
||||
) -> StringList:
|
||||
options = {} if options is None else options.copy()
|
||||
app.env.temp_data.setdefault('docname', 'index') # set dummy docname
|
||||
if not app.env.current_document.docname:
|
||||
app.env.current_document.docname = 'index' # set dummy docname
|
||||
doccls = app.registry.documenters[objtype]
|
||||
docoptions = process_documenter_options(doccls, app.config, options)
|
||||
state = Mock()
|
||||
|
@@ -95,9 +95,10 @@ def test_parse_name(app):
|
||||
'test_ext_autodoc.raises(exc) -> None',
|
||||
('test_ext_autodoc', ['raises'], 'exc', 'None'),
|
||||
)
|
||||
directive.env.temp_data['autodoc:module'] = 'test_ext_autodoc'
|
||||
directive.env.current_document.autodoc_module = 'test_ext_autodoc'
|
||||
verify('function', 'raises', ('test_ext_autodoc', ['raises'], None, None))
|
||||
del directive.env.temp_data['autodoc:module']
|
||||
directive.env.current_document.autodoc_module = ''
|
||||
|
||||
directive.env.ref_context['py:module'] = 'test_ext_autodoc'
|
||||
verify('function', 'raises', ('test_ext_autodoc', ['raises'], None, None))
|
||||
verify('class', 'Base', ('test_ext_autodoc', ['Base'], None, None))
|
||||
@@ -111,7 +112,7 @@ def test_parse_name(app):
|
||||
)
|
||||
directive.env.ref_context['py:module'] = 'sphinx.testing.util'
|
||||
directive.env.ref_context['py:class'] = 'Foo'
|
||||
directive.env.temp_data['autodoc:class'] = 'SphinxTestApp'
|
||||
directive.env.current_document.autodoc_class = 'SphinxTestApp'
|
||||
verify(
|
||||
'method',
|
||||
'cleanup',
|
||||
@@ -526,7 +527,7 @@ def test_autodoc_exception(app):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_warnings(app):
|
||||
app.env.temp_data['docname'] = 'dummy'
|
||||
app.env.current_document.docname = 'dummy'
|
||||
|
||||
# can't import module
|
||||
do_autodoc(app, 'module', 'unknown')
|
||||
@@ -1299,7 +1300,7 @@ def test_autodoc_module_member_order(app):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_module_scope(app):
|
||||
app.env.temp_data['autodoc:module'] = 'target'
|
||||
app.env.current_document.autodoc_module = 'target'
|
||||
actual = do_autodoc(app, 'attribute', 'Class.mdocattr')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
@@ -1314,8 +1315,8 @@ def test_autodoc_module_scope(app):
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_class_scope(app):
|
||||
app.env.temp_data['autodoc:module'] = 'target'
|
||||
app.env.temp_data['autodoc:class'] = 'Class'
|
||||
app.env.current_document.autodoc_module = 'target'
|
||||
app.env.current_document.autodoc_class = 'Class'
|
||||
actual = do_autodoc(app, 'attribute', 'mdocattr')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
|
Reference in New Issue
Block a user