mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
[intersphinx] allow case-insensitive match of label-refs through intersphinx (#12033)
This commit is contained in:
@@ -84,6 +84,8 @@ Bugs fixed
|
||||
Patch by James Addison.
|
||||
* #11962: Fix target resolution when using ``:paramtype:`` fields.
|
||||
Patch by Bénédikt Tran.
|
||||
* #12008: Fix case-sensitive lookup of ``std:label`` names in intersphinx inventory.
|
||||
Patch by Michael Goerz.
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
@@ -334,8 +334,10 @@ def _resolve_reference_in_domain_by_target(
|
||||
if target in inventory[objtype]:
|
||||
# Case sensitive match, use it
|
||||
data = inventory[objtype][target]
|
||||
elif objtype == 'std:term':
|
||||
# Check for potential case insensitive matches for terms only
|
||||
elif objtype in {'std:label', 'std:term'}:
|
||||
# Some types require case insensitive matches:
|
||||
# * 'term': https://github.com/sphinx-doc/sphinx/issues/9291
|
||||
# * 'label': https://github.com/sphinx-doc/sphinx/issues/12008
|
||||
target_lower = target.lower()
|
||||
insensitive_matches = list(filter(lambda k: k.lower() == target_lower,
|
||||
inventory[objtype].keys()))
|
||||
|
||||
@@ -236,6 +236,16 @@ def test_missing_reference_stddomain(tmp_path, app, status, warning):
|
||||
rn = missing_reference(app, app.env, node, contnode)
|
||||
assert rn.astext() == 'A TERM'
|
||||
|
||||
# label reference (normal)
|
||||
node, contnode = fake_node('std', 'ref', 'The-Julia-Domain', 'The-Julia-Domain')
|
||||
rn = missing_reference(app, app.env, node, contnode)
|
||||
assert rn.astext() == 'The Julia Domain'
|
||||
|
||||
# label reference (case insensitive)
|
||||
node, contnode = fake_node('std', 'ref', 'the-julia-domain', 'the-julia-domain')
|
||||
rn = missing_reference(app, app.env, node, contnode)
|
||||
assert rn.astext() == 'The Julia Domain'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-intersphinx-cppdomain')
|
||||
def test_missing_reference_cppdomain(tmp_path, app, status, warning):
|
||||
|
||||
@@ -41,6 +41,7 @@ foo.bar js:class 1 index.html#foo.bar -
|
||||
foo.bar.baz js:method 1 index.html#foo.bar.baz -
|
||||
foo.bar.qux js:data 1 index.html#foo.bar.qux -
|
||||
a term including:colon std:term -1 glossary.html#term-a-term-including-colon -
|
||||
The-Julia-Domain std:label -1 write_inventory/#$ The Julia Domain
|
||||
''')
|
||||
|
||||
inventory_v2_not_having_version = b'''\
|
||||
|
||||
Reference in New Issue
Block a user