Skip to content

Commit 265ffee

Browse files
authored
[intersphinx] allow case-insensitive match of label-refs through intersphinx (#12033)
1 parent 9a30ca7 commit 265ffee

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ Bugs fixed
8484
Patch by James Addison.
8585
* #11962: Fix target resolution when using ``:paramtype:`` fields.
8686
Patch by Bénédikt Tran.
87+
* #12008: Fix case-sensitive lookup of ``std:label`` names in intersphinx inventory.
88+
Patch by Michael Goerz.
8789

8890
Testing
8991
-------

sphinx/ext/intersphinx.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,10 @@ def _resolve_reference_in_domain_by_target(
334334
if target in inventory[objtype]:
335335
# Case sensitive match, use it
336336
data = inventory[objtype][target]
337-
elif objtype == 'std:term':
338-
# Check for potential case insensitive matches for terms only
337+
elif objtype in {'std:label', 'std:term'}:
338+
# Some types require case insensitive matches:
339+
# * 'term': https://github.com/sphinx-doc/sphinx/issues/9291
340+
# * 'label': https://github.com/sphinx-doc/sphinx/issues/12008
339341
target_lower = target.lower()
340342
insensitive_matches = list(filter(lambda k: k.lower() == target_lower,
341343
inventory[objtype].keys()))

tests/test_extensions/test_ext_intersphinx.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,16 @@ def test_missing_reference_stddomain(tmp_path, app, status, warning):
236236
rn = missing_reference(app, app.env, node, contnode)
237237
assert rn.astext() == 'A TERM'
238238

239+
# label reference (normal)
240+
node, contnode = fake_node('std', 'ref', 'The-Julia-Domain', 'The-Julia-Domain')
241+
rn = missing_reference(app, app.env, node, contnode)
242+
assert rn.astext() == 'The Julia Domain'
243+
244+
# label reference (case insensitive)
245+
node, contnode = fake_node('std', 'ref', 'the-julia-domain', 'the-julia-domain')
246+
rn = missing_reference(app, app.env, node, contnode)
247+
assert rn.astext() == 'The Julia Domain'
248+
239249

240250
@pytest.mark.sphinx('html', testroot='ext-intersphinx-cppdomain')
241251
def test_missing_reference_cppdomain(tmp_path, app, status, warning):

tests/test_util/test_util_inventory.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
foo.bar.baz js:method 1 index.html#foo.bar.baz -
4242
foo.bar.qux js:data 1 index.html#foo.bar.qux -
4343
a term including:colon std:term -1 glossary.html#term-a-term-including-colon -
44+
The-Julia-Domain std:label -1 write_inventory/#$ The Julia Domain
4445
''')
4546

4647
inventory_v2_not_having_version = b'''\

0 commit comments

Comments
 (0)