Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.

Commit ad8a82d

Browse files
shiftinvhumitos
andauthored
Handle explicit intersphinx inventory names in all domains (#236)
fix: handle intersphinx inventory names in all domains Co-authored-by: Manuel Kaufmann <[email protected]>
1 parent 52afd61 commit ad8a82d

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

hoverxref/extension.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,19 +222,18 @@ def missing_reference(app, env, node, contnode):
222222
skip_node = True
223223
inventory_name_matched = None
224224

225-
if domain == 'std':
226-
# Using ``:ref:`` manually, we could write intersphinx like:
225+
if ':' in target:
226+
# Using intersphinx with an explicit inventory name like:
227227
# :ref:`datetime <python:datetime.datetime>`
228228
# and the node will have these attribues:
229229
# refdomain: std
230230
# reftype: ref
231231
# reftarget: python:datetime.datetime
232232
# refexplicit: True
233-
if ':' in target:
234-
inventory_name, _ = target.split(':', 1)
235-
if inventory_name in app.config.hoverxref_intersphinx:
236-
skip_node = False
237-
inventory_name_matched = inventory_name
233+
inventory_name, _ = target.split(':', 1)
234+
if inventory_name in app.config.hoverxref_intersphinx:
235+
skip_node = False
236+
inventory_name_matched = inventory_name
238237

239238
# Skip this node completely if the domain is empty (`None` or `''`).
240239
# I found this happens in weird scenarios.

tests/examples/intersphinx/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This is an example page.
55

66
:ref:`This a :ref: to The Python Tutorial using intersphinx <python:tutorial-index>`.
77
:ref:`This a :ref: to datetime.datetime Python's function using intersphinx <python:datetime-datetime>`.
8+
:py:attr:`Python's datetime.time.minute <python:datetime.time.minute>`.
89

910
:ref:`This a :ref: to Config File v2 Read the Docs' page using intersphinx <readthedocs:config-file/v2:python>`.
1011

tests/test_htmltag.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ def test_intersphinx_all_mappings(app, status, warning):
351351
# Python's links do have hoverxref enabled
352352
r'<a class="hxr-hoverxref hxr-tooltip reference external" href="https://docs.python.org/3/tutorial/index.html#tutorial-index" title="\(in Python v3.\d\d?\)"><span class="xref std std-ref">This a :ref: to The Python Tutorial using intersphinx</span></a>',
353353
r'<a class="hxr-hoverxref hxr-tooltip reference external" href="https://docs.python.org/3/library/datetime.html#datetime-datetime" title="\(in Python v3.\d\d?\)"><span class="xref std std-ref">This a :ref: to datetime.datetime Python’s function using intersphinx</span></a>',
354+
r'<a class="hxr-hoverxref hxr-tooltip reference external" href="https://docs.python.org/3/library/datetime.html#datetime.time.minute" title="\(in Python v3.\d\d?\)"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Python\'s</span> <span class="pre">datetime.time.minute</span></code></a>',
354355
r'<a class="hxr-hoverxref hxr-modal reference external" href="https://docs.python.org/3/library/functions.html#float" title="\(in Python v3.\d\d?\)"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>',
355356

356357
# Read the Docs' link does have hoverxref enabled

0 commit comments

Comments
 (0)