Skip to content

Commit af03ce8

Browse files
committed
reftype fallbacks
Borrowed from #144
1 parent 0096aee commit af03ce8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

hoverxref/extension.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,20 @@ def missing_reference(app, env, node, contnode):
222222
# refexplicit: False
223223
inventories = InventoryAdapter(env)
224224

225+
# TODO: credits to https://github.com/readthedocs/sphinx-hoverxref/pull/144
226+
# This chunk of code needs tests :)
227+
reftype_fallbacks = {
228+
'meth': 'method',
229+
'mod': 'module',
230+
}
231+
225232
for inventory_name in app.config.hoverxref_intersphinx:
226233
inventory = inventories.named_inventory.get(inventory_name, {})
227-
if inventory.get(f'{domain}:{reftype}', {}).get(target) is not None:
234+
inventory_member = (
235+
inventory.get(f'{domain}:{reftype}') or
236+
inventory.get(f'{domain}:{reftype_fallbacks.get(reftype)}')
237+
)
238+
if inventory_member and inventory_member.get(target) is not None:
228239
# The object **does** exist on the inventories defined by the
229240
# user: enable hoverxref on this node
230241
skip_node = False

0 commit comments

Comments
 (0)