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

Commit 0a75b73

Browse files
committed
Do not remove reftitle because it breaks other extensions
#86 (comment) There are other extensions that expect `reftitle` to be an attribute in the node. They are doing `node['reftitle']` without checking if it exists first. This happens in `sphinx.ext.inheritance_diagram` which is a built-in extension. So it's preferrable to not modify the node and find another way to remove the browser's tooltip later. See https://github.com/sphinx-doc/sphinx/blob/4.x/sphinx/ext/inheritance_diagram.py#L413
1 parent 8b78377 commit 0a75b73

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

hoverxref/extension.py

-5
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,6 @@ def missing_reference(app, env, node, contnode):
241241
'data-url': newnode.get('refuri'),
242242
}
243243

244-
# Remove ``title=`` from HTML tag to avoid showing the title of the
245-
# reference when hovering, which is a little confusing
246-
if 'reftitle' in newnode:
247-
del newnode['reftitle']
248-
249244
return newnode
250245

251246

tests/test_htmltag.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ def test_intersphinx_python_mapping(app, status, warning):
252252

253253
chunks = [
254254
# Python's links do have hoverxref enabled
255-
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/tutorial/index.html#tutorial-index" href="https://docs.python.org/3/tutorial/index.html#tutorial-index"><span class="xref std std-ref">This a :ref: to The Python Tutorial using intersphinx</span></a>',
256-
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/library/datetime.html#datetime-datetime" href="https://docs.python.org/3/library/datetime.html#datetime-datetime"><span class="xref std std-ref">This a :ref: to datetime.datetime Python’s function using intersphinx</span></a>',
257-
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/library/functions.html#float" href="https://docs.python.org/3/library/functions.html#float"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>',
255+
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/tutorial/index.html#tutorial-index" href="https://docs.python.org/3/tutorial/index.html#tutorial-index" title="(in Python v3.9)"><span class="xref std std-ref">This a :ref: to The Python Tutorial using intersphinx</span></a>',
256+
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/library/datetime.html#datetime-datetime" href="https://docs.python.org/3/library/datetime.html#datetime-datetime" title="(in Python v3.9)"><span class="xref std std-ref">This a :ref: to datetime.datetime Python’s function using intersphinx</span></a>',
257+
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/library/functions.html#float" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.9)"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>',
258258

259259
# Read the Docs' link does not have hoverxref enabled
260260
'<a class="reference external" href="https://docs.readthedocs.io/en/stable/config-file/v2.html#python" title="(in Read the Docs v5.17.0)"><span class="xref std std-ref">This a :ref: to Config File v2 Read the Docs’ page using intersphinx</span></a>',
@@ -288,12 +288,12 @@ def test_intersphinx_all_mappings(app, status, warning):
288288

289289
chunks = [
290290
# Python's links do have hoverxref enabled
291-
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/tutorial/index.html#tutorial-index" href="https://docs.python.org/3/tutorial/index.html#tutorial-index"><span class="xref std std-ref">This a :ref: to The Python Tutorial using intersphinx</span></a>',
292-
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/library/datetime.html#datetime-datetime" href="https://docs.python.org/3/library/datetime.html#datetime-datetime"><span class="xref std std-ref">This a :ref: to datetime.datetime Python’s function using intersphinx</span></a>',
293-
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/library/functions.html#float" href="https://docs.python.org/3/library/functions.html#float"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>',
291+
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/tutorial/index.html#tutorial-index" href="https://docs.python.org/3/tutorial/index.html#tutorial-index" title="(in Python v3.9)"><span class="xref std std-ref">This a :ref: to The Python Tutorial using intersphinx</span></a>',
292+
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/library/datetime.html#datetime-datetime" href="https://docs.python.org/3/library/datetime.html#datetime-datetime" title="(in Python v3.9)"><span class="xref std std-ref">This a :ref: to datetime.datetime Python’s function using intersphinx</span></a>',
293+
'<a class="hoverxref tooltip reference external" data-url="https://docs.python.org/3/library/functions.html#float" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.9)"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>',
294294

295295
# Read the Docs' link does have hoverxref enabled
296-
'<a class="hoverxref modal reference external" data-url="https://docs.readthedocs.io/en/stable/config-file/v2.html#python" href="https://docs.readthedocs.io/en/stable/config-file/v2.html#python"><span class="xref std std-ref">This a :ref: to Config File v2 Read the Docs’ page using intersphinx</span></a>',
296+
'<a class="hoverxref modal reference external" data-url="https://docs.readthedocs.io/en/stable/config-file/v2.html#python" href="https://docs.readthedocs.io/en/stable/config-file/v2.html#python" title="(in Read the Docs v5.17.0)"><span class="xref std std-ref">This a :ref: to Config File v2 Read the Docs’ page using intersphinx</span></a>',
297297

298298
# Python domain's link does have hoverxref enabled
299299
'<a class="hoverxref tooltip reference internal" data-doc="index" data-docpath="/index.html" data-project="myproject" data-section="hoverxref.extension.setup" data-version="myversion" href="#hoverxref.extension.setup" title="hoverxref.extension.setup"><code class="xref py py-func docutils literal notranslate"><span class="pre">hoverxref.extension.setup()</span></code></a>',

0 commit comments

Comments
 (0)