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

Fix Pytorch theme not activating jQuery #497

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/qiskit_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@ def remove_thebe_if_not_needed(
]


def activate_themes(app: sphinx.application.Sphinx, config: sphinx.config.Config) -> None:
if config.html_theme in ["qiskit", "_qiskit-ecosystem"]:
# We set a low priority so that our Qiskit CSS file overrides Furo.
app.add_css_file("styles/furo.css", 100)
app.add_js_file("scripts/qiskit-sphinx-theme.js")
Eric-Arellano marked this conversation as resolved.
Show resolved Hide resolved
else:
# Sphinx 6 stopped including jQuery by default. Our Pytorch theme depend on jQuery,
# so activate it for our users automatically.
app.setup_extension("sphinxcontrib.jquery")
def activate_furo(app: sphinx.application.Sphinx, config: sphinx.config.Config) -> None:
if config.html_theme == "qiskit_sphinx_theme":
return
# We set a low priority so that our Qiskit CSS file overrides Furo.
app.add_css_file("styles/furo.css", 100)
app.add_js_file("scripts/qiskit-sphinx-theme.js")


def remove_furo_js(
Expand All @@ -95,6 +92,11 @@ def setup(app: sphinx.application.Sphinx) -> dict[str, bool]:
# Used to generate URL references. Expected to be e.g. `ecosystem/finance`.
app.add_config_value("docs_url_prefix", default=None, rebuild="html", types=[str])

# Sphinx 6 stopped including jQuery by default. Our Pytorch theme depend on jQuery,
# so activate it for our users automatically. Unfortunately, we can't make this activation
# conditional based on which theme is chosen.
app.setup_extension("sphinxcontrib.jquery")
coruscating marked this conversation as resolved.
Show resolved Hide resolved

# We always activate these plugins, but they are only used when users:
# * use the directives in their RST,
# * set `translations_list` in conf.py, or
Expand All @@ -107,7 +109,7 @@ def setup(app: sphinx.application.Sphinx) -> dict[str, bool]:
app.add_html_theme("qiskit", _get_theme_absolute_path("theme/qiskit-sphinx-theme"))
app.add_html_theme("_qiskit-ecosystem", _get_theme_absolute_path("ecosystem"))

app.connect("config-inited", activate_themes)
app.connect("config-inited", activate_furo)
app.connect("html-page-context", remove_furo_js, priority=600)
app.connect("html-page-context", remove_thebe_if_not_needed)

Expand Down
Loading