Skip to content

Commit f02c06f

Browse files
committed
Setup Sphinx Tabs from the extension itself
1 parent 1deb83b commit f02c06f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

hoverxref/extension.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import inspect
23
from docutils import nodes
34
from sphinx.domains.python import PythonDomain
45
from sphinx.domains.std import StandardDomain
@@ -194,6 +195,19 @@ def setup_domains(app, config):
194195
app.add_domain(HoverXRefPythonDomain, override=True)
195196

196197

198+
def setup_sphinx_tabs(app, config):
199+
"""
200+
Disconnect ``update_context`` function from ``sphinx-tabs``.
201+
202+
Sphinx Tabs removes the CSS/JS from pages that does not use the directive.
203+
Although, we need them to use inside the tooltip.
204+
"""
205+
for listener_id, function in app.events.listeners.get('html-page-context').items():
206+
module_name = inspect.getmodule(function).__name__
207+
if module_name == 'sphinx_tabs.tabs':
208+
app.disconnect(listener_id)
209+
210+
197211
def setup(app):
198212
"""Setup ``hoverxref`` Sphinx extension."""
199213

@@ -225,6 +239,7 @@ def setup(app):
225239
app.set_translator('readthedocs', HoverXRefHTMLTranslator, override=True)
226240

227241
app.connect('config-inited', setup_domains)
242+
app.connect('config-inited', setup_sphinx_tabs)
228243
app.connect('build-finished', copy_asset_files)
229244

230245
for f in ASSETS_FILES:

0 commit comments

Comments
 (0)