mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
intersphinx: Don't warn about pure-duplicate ambiguous definitions when loading inventory entries (#12586)
This commit is contained in:
@@ -126,7 +126,8 @@ class InventoryFile:
|
||||
invdata: Inventory = {}
|
||||
projname = stream.readline().rstrip()[11:]
|
||||
version = stream.readline().rstrip()[11:]
|
||||
potential_ambiguities = set()
|
||||
# definition -> priority, location, display name
|
||||
potential_ambiguities: dict[str, tuple[str, str, str]] = {}
|
||||
actual_ambiguities = set()
|
||||
line = stream.readline()
|
||||
if 'zlib' not in line:
|
||||
@@ -155,10 +156,16 @@ class InventoryFile:
|
||||
# * 'term': https://github.com/sphinx-doc/sphinx/issues/9291
|
||||
# * 'label': https://github.com/sphinx-doc/sphinx/issues/12008
|
||||
definition = f"{type}:{name}"
|
||||
if definition.lower() in potential_ambiguities:
|
||||
actual_ambiguities.add(definition)
|
||||
content = prio, location, dispname
|
||||
lowercase_definition = definition.lower()
|
||||
if lowercase_definition in potential_ambiguities:
|
||||
if potential_ambiguities[lowercase_definition] != content:
|
||||
actual_ambiguities.add(definition)
|
||||
else:
|
||||
logger.debug(__("inventory <%s> contains duplicate definitions of %s"),
|
||||
uri, definition, type='intersphinx', subtype='external')
|
||||
else:
|
||||
potential_ambiguities.add(definition.lower())
|
||||
potential_ambiguities[lowercase_definition] = content
|
||||
if location.endswith('$'):
|
||||
location = location[:-1] + name
|
||||
location = join(uri, location)
|
||||
|
||||
@@ -59,4 +59,6 @@ INVENTORY_V2_AMBIGUOUS_TERMS: Final[bytes] = b'''\
|
||||
''' + zlib.compress(b'''\
|
||||
a term std:term -1 glossary.html#term-a-term -
|
||||
A term std:term -1 glossary.html#term-a-term -
|
||||
b term std:term -1 document.html#id5 -
|
||||
B term std:term -1 document.html#B -
|
||||
''')
|
||||
|
||||
@@ -53,7 +53,8 @@ def test_ambiguous_definition_warning(warning):
|
||||
f = BytesIO(INVENTORY_V2_AMBIGUOUS_TERMS)
|
||||
InventoryFile.load(f, '/util', posixpath.join)
|
||||
|
||||
assert 'contains multiple definitions for std:term:a' in warning.getvalue().lower()
|
||||
assert 'contains multiple definitions for std:term:a' not in warning.getvalue().lower()
|
||||
assert 'contains multiple definitions for std:term:b' in warning.getvalue().lower()
|
||||
|
||||
|
||||
def _write_appconfig(dir, language, prefix=None):
|
||||
|
||||
Reference in New Issue
Block a user