mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-08-10 04:58:20 -05:00
Merge branch '3.x'
This commit is contained in:
@@ -34,6 +34,23 @@ def test_process_docstring(app):
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_process_docstring_for_nondatadescriptor(app):
|
||||
def on_process_docstring(app, what, name, obj, options, lines):
|
||||
raise
|
||||
|
||||
app.connect('autodoc-process-docstring', on_process_docstring)
|
||||
|
||||
actual = do_autodoc(app, 'attribute', 'target.AttCls.a1')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:attribute:: AttCls.a1',
|
||||
' :module: target',
|
||||
' :value: hello world',
|
||||
'',
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_cut_lines(app):
|
||||
app.connect('autodoc-process-docstring',
|
||||
|
||||
@@ -378,48 +378,45 @@ def test_autosummary_generate_overwrite2(app_params, make_app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-recursive')
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_autosummary_recursive(app, status, warning):
|
||||
try:
|
||||
app.build()
|
||||
sys.modules.pop('package', None) # unload target module to clear the module cache
|
||||
|
||||
# autosummary having :recursive: option
|
||||
assert (app.srcdir / 'generated' / 'package.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.module.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.module_importfail.rst').exists() is False
|
||||
assert (app.srcdir / 'generated' / 'package.package.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.package.module.rst').exists()
|
||||
app.build()
|
||||
|
||||
# autosummary not having :recursive: option
|
||||
assert (app.srcdir / 'generated' / 'package2.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package2.module.rst').exists() is False
|
||||
# autosummary having :recursive: option
|
||||
assert (app.srcdir / 'generated' / 'package.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.module.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.module_importfail.rst').exists() is False
|
||||
assert (app.srcdir / 'generated' / 'package.package.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.package.module.rst').exists()
|
||||
|
||||
# Check content of recursively generated stub-files
|
||||
content = (app.srcdir / 'generated' / 'package.rst').read_text()
|
||||
assert 'package.module' in content
|
||||
assert 'package.package' in content
|
||||
assert 'package.module_importfail' in content
|
||||
# autosummary not having :recursive: option
|
||||
assert (app.srcdir / 'generated' / 'package2.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package2.module.rst').exists() is False
|
||||
|
||||
content = (app.srcdir / 'generated' / 'package.package.rst').read_text()
|
||||
assert 'package.package.module' in content
|
||||
finally:
|
||||
sys.modules.pop('package.package', None)
|
||||
sys.modules.pop('package.package.module', None)
|
||||
# Check content of recursively generated stub-files
|
||||
content = (app.srcdir / 'generated' / 'package.rst').read_text()
|
||||
assert 'package.module' in content
|
||||
assert 'package.package' in content
|
||||
assert 'package.module_importfail' in content
|
||||
|
||||
content = (app.srcdir / 'generated' / 'package.package.rst').read_text()
|
||||
assert 'package.package.module' in content
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-recursive',
|
||||
srcdir='test_autosummary_recursive_skips_mocked_modules',
|
||||
confoverrides={'autosummary_mock_imports': ['package.package']})
|
||||
@pytest.mark.usefixtures("rollback_sysmodules")
|
||||
def test_autosummary_recursive_skips_mocked_modules(app, status, warning):
|
||||
try:
|
||||
app.build()
|
||||
sys.modules.pop('package', None) # unload target module to clear the module cache
|
||||
app.build()
|
||||
|
||||
assert (app.srcdir / 'generated' / 'package.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.module.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.package.rst').exists() is False
|
||||
assert (app.srcdir / 'generated' / 'package.package.module.rst').exists() is False
|
||||
finally:
|
||||
sys.modules.pop('package.package', None)
|
||||
sys.modules.pop('package.package.module', None)
|
||||
assert (app.srcdir / 'generated' / 'package.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.module.rst').exists()
|
||||
assert (app.srcdir / 'generated' / 'package.package.rst').exists() is False
|
||||
assert (app.srcdir / 'generated' / 'package.package.module.rst').exists() is False
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='ext-autosummary-filename-map')
|
||||
|
||||
@@ -244,7 +244,7 @@ def get_verifier(verify, verify_re):
|
||||
# kbd role
|
||||
'verify',
|
||||
':kbd:`Control+X`',
|
||||
('<p><kbd class="kbd docutils literal notranslate">'
|
||||
('<p><kbd class="kbd compound docutils literal notranslate">'
|
||||
'<kbd class="kbd docutils literal notranslate">Control</kbd>'
|
||||
'+'
|
||||
'<kbd class="kbd docutils literal notranslate">X</kbd>'
|
||||
@@ -255,7 +255,7 @@ def get_verifier(verify, verify_re):
|
||||
# kbd role
|
||||
'verify',
|
||||
':kbd:`Alt+^`',
|
||||
('<p><kbd class="kbd docutils literal notranslate">'
|
||||
('<p><kbd class="kbd compound docutils literal notranslate">'
|
||||
'<kbd class="kbd docutils literal notranslate">Alt</kbd>'
|
||||
'+'
|
||||
'<kbd class="kbd docutils literal notranslate">^</kbd>'
|
||||
@@ -266,7 +266,7 @@ def get_verifier(verify, verify_re):
|
||||
# kbd role
|
||||
'verify',
|
||||
':kbd:`M-x M-s`',
|
||||
('<p><kbd class="kbd docutils literal notranslate">'
|
||||
('<p><kbd class="kbd compound docutils literal notranslate">'
|
||||
'<kbd class="kbd docutils literal notranslate">M</kbd>'
|
||||
'-'
|
||||
'<kbd class="kbd docutils literal notranslate">x</kbd>'
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
import sys
|
||||
from numbers import Integral
|
||||
from struct import Struct
|
||||
from typing import (Any, Callable, Dict, Generator, List, NewType, Optional, Tuple, TypeVar,
|
||||
Union)
|
||||
|
||||
@@ -43,6 +44,7 @@ def test_restify():
|
||||
assert restify(str) == ":class:`str`"
|
||||
assert restify(None) == ":obj:`None`"
|
||||
assert restify(Integral) == ":class:`numbers.Integral`"
|
||||
assert restify(Struct) == ":class:`struct.Struct`"
|
||||
assert restify(Any) == ":obj:`Any`"
|
||||
|
||||
|
||||
@@ -124,6 +126,7 @@ def test_stringify():
|
||||
assert stringify(str) == "str"
|
||||
assert stringify(None) == "None"
|
||||
assert stringify(Integral) == "numbers.Integral"
|
||||
assert restify(Struct) == ":class:`struct.Struct`"
|
||||
assert stringify(Any) == "Any"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user