Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow case-insensitive match of :term: references through intersphinx #9299

Merged
merged 2 commits into from Jul 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions sphinx/ext/intersphinx.py
Expand Up @@ -305,9 +305,19 @@ def missing_reference(app: Sphinx, env: BuildEnvironment, node: pending_xref,
to_try.append((inventories.named_inventory[setname], full_qualified_name))
for inventory, target in to_try:
for objtype in objtypes:
if objtype not in inventory or target not in inventory[objtype]:
continue
proj, version, uri, dispname = inventory[objtype][target]
# Special case handling for term to search in a case insensitive fashion
if objtype == 'std:term' and objtype in inventory:
cased_keys = {k.lower(): k for k in inventory[objtype].keys()}
tk0miya marked this conversation as resolved.
Show resolved Hide resolved
if target.lower() in cased_keys:
corrected_target = cased_keys[target.lower()]
proj, version, uri, dispname = inventory[objtype][corrected_target]
else:
continue
else:
# Default behaviour pre-patch
if objtype not in inventory or target not in inventory[objtype]:
continue
proj, version, uri, dispname = inventory[objtype][target]
if '://' not in uri and node.get('refdoc'):
# get correct path in case of subdirectories
uri = path.join(relative_path(node['refdoc'], '.'), uri)
Expand Down