mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
test: Add testcase for relative/short xref for py domain
This commit is contained in:
parent
7acafa991b
commit
a3df1d00c7
10
tests/roots/test-domain-py/abbr.rst
Normal file
10
tests/roots/test-domain-py/abbr.rst
Normal file
@ -0,0 +1,10 @@
|
||||
abbrev
|
||||
======
|
||||
|
||||
.. currentmodule:: module_a.submodule
|
||||
|
||||
* normal: :py:meth:`module_a.submodule.ModTopLevel.mod_child_1`
|
||||
* relative: :py:meth:`.ModTopLevel.mod_child_1`
|
||||
* short name: :py:meth:`~module_a.submodule.ModTopLevel.mod_child_1`
|
||||
* relative + short name: :py:meth:`~.ModTopLevel.mod_child_1`
|
||||
* short name + relative: :py:meth:`~.ModTopLevel.mod_child_1`
|
@ -8,6 +8,7 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
from unittest.mock import Mock
|
||||
|
||||
@ -132,6 +133,29 @@ def test_domain_py_xrefs(app, status, warning):
|
||||
assert len(refnodes) == 2
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='domain-py')
|
||||
def test_domain_py_xrefs_abbreviations(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'abbr.html').read_text()
|
||||
assert re.search(r'normal: <a .* href="module.html#module_a.submodule.ModTopLevel.'
|
||||
r'mod_child_1" .*><.*>module_a.submodule.ModTopLevel.mod_child_1\(\)'
|
||||
r'<.*></a>',
|
||||
content)
|
||||
assert re.search(r'relative: <a .* href="module.html#module_a.submodule.ModTopLevel.'
|
||||
r'mod_child_1" .*><.*>ModTopLevel.mod_child_1\(\)<.*></a>',
|
||||
content)
|
||||
assert re.search(r'short name: <a .* href="module.html#module_a.submodule.ModTopLevel.'
|
||||
r'mod_child_1" .*><.*>mod_child_1\(\)<.*></a>',
|
||||
content)
|
||||
assert re.search(r'relative \+ short name: <a .* href="module.html#module_a.submodule.'
|
||||
r'ModTopLevel.mod_child_1" .*><.*>mod_child_1\(\)<.*></a>',
|
||||
content)
|
||||
assert re.search(r'short name \+ relative: <a .* href="module.html#module_a.submodule.'
|
||||
r'ModTopLevel.mod_child_1" .*><.*>mod_child_1\(\)<.*></a>',
|
||||
content)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-py')
|
||||
def test_domain_py_objects(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
Loading…
Reference in New Issue
Block a user