Skip to content

Commit

Permalink
Normalize name for 'std:label' when loading inventory
Browse files Browse the repository at this point in the history
Lowercase the `name` for any inventory item of type `std:label` to match
the lowercaseing of `ref` and `numeref` references in the `std` domain.
  • Loading branch information
goerz committed Feb 25, 2024
1 parent 8aa5edd commit 250400f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sphinx/util/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 138,11 @@ def load_v2(
continue
if location.endswith('$'):
location = location[:-1] name
if type == 'std:label':
# Normalize names for `:std:label` to match
# `XRefRole(lowercase=True)` for `ref` and `numref` roles.
# See https://github.com/sphinx-doc/sphinx/issues/12008
name = name.lower()
location = join(uri, location)
inv_item: InventoryItem = projname, version, location, dispname
invdata.setdefault(type, {})[name] = inv_item
Expand Down
2 changes: 2 additions & 0 deletions tests/test_util/test_util_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 41,7 @@
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'''\
Expand Down Expand Up @@ -78,6 79,7 @@ def test_read_inventory_v2():
'/util/glossary.html#term-a-term'
assert invdata['std:term']['a term including:colon'][2] == \
'/util/glossary.html#term-a-term-including-colon'
assert "The-Julia-Domain" in invdata['std:label']


def test_read_inventory_v2_not_having_version():
Expand Down

0 comments on commit 250400f

Please sign in to comment.