-
Notifications
You must be signed in to change notification settings - Fork 30
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
Language switcher doesn't work in Runtime docs and Nature docs #272
Comments
Thanks for this report! It should not be #255 - that is only on the It looks like this has been broken for some time. The missing content for Finance, ML, Opt, etc is because their files diff --git a/docs/versionutils.py b/docs/versionutils.py
index 92033c4..3ad5248 100644
--- a/docs/versionutils.py
+++ b/docs/versionutils.py
@@ -46,7 +46,7 @@ def _extend_html_context(app, config):
context["translations_list"] = translations_list
context["current_translation"] = _get_current_translation(config) or config.language
context["translation_url"] = partial(_get_translation_url, config)
- context["version_label"] = _get_version_label(config)
+ context["language_label"] = _get_version_label(config)
def _get_current_translation(config): The reason that it's not clickable on Runtime and Nature is that jQuery is missing so the JavaScript code we have does not work. That is because Sphinx 5 used to include jQuery, but Sphinx 6 no longer does. The workaround is to install diff --git a/docs/conf.py b/docs/conf.py
index 0d1754b..eef7ee1 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -99,6 +99,7 @@ extensions = [
"sphinx.ext.doctest",
"nbsphinx",
"sphinx.ext.intersphinx",
+ "sphinxcontrib.jquery",
]
html_static_path = ["_static"]
templates_path = ["_templates"]
diff --git a/docs/versionutils.py b/docs/versionutils.py
index 29702e5..8305b5b 100644
--- a/docs/versionutils.py
+++ b/docs/versionutils.py
@@ -46,7 +46,7 @@ def _extend_html_context(app, config):
context["translations_list"] = translations_list
context["current_translation"] = _get_current_translation(config) or config.language
context["translation_url"] = partial(_get_translation_url, config)
- context["version_label"] = _get_version_label(config)
+ context["language_label"] = _get_version_label(config)
def _get_current_translation(config):
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 5e96877..d5fb701 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -18,3 +18,4 @@ mypy-extensions>=0.4.3
nbsphinx
qiskit_sphinx_theme>=1.10
networkx>=2.2,<2.6
+sphinxcontrib-jquery I'm not sure why the other applications and Terra are working. They must be installing jQuery some other way. We should not be using jQuery anymore though: I opened #275 to track this and will release 1.11.1 to include jQuery with the Qiskit Sphinx Theme: #276. -- Taking a step back, it is not sustainable for each repository to have its own This should be provided for you by qiskit_sphinx_theme, IMO. At most, you only have to configure what languages you want. I will submit soon PRs to each repo with the short-term fixes. But I also propose that the theme 1.12 starts including versionutils.py for you so that this Just Works in the future. (Along with other structural fixes for Ecosystem projects like #267) |
…r JavaScript issues (#277) Sphinx 6 stopped including jQuery by default, but we're still using it in some places. As a result, the docs' functionality is broken in some places like the language selection not being clickable: #272 I wanted to remove jQuery via #275, but it is too hard to safely due with Pytorch because we have 105 usages. We will need to wait for the switch to Furo. So, for now, we will include jQuery by default. We also try to activate the extension by default with the line `app.setup_extension("sphinxcontrib.jquery"),` but I'm having issues with that actually working. So, projects may need to still add `"sphinxcontrib.jquery"` explicitly in their extensions in `conf.py` - but they at least won't have to explicitly include `sphinxcontrib-jquery` in their requirements. -- This PR also fixes other issues with our JavaScript, as reported by the developer console: 1. `languages.html` was not recognizing jQuery. So, rewrite it to modern JavaScript 2. `pytorchAnchors.bind();` was not defined so caused some of our setup to fail 3. `handleLeftMenu:` function was failing because `document.getElementById("docs-tutorials-resources")` does not exist. Since that function failed, it looks like it wasn't actually necessary anymore.
…r JavaScript issues (Qiskit#277) Sphinx 6 stopped including jQuery by default, but we're still using it in some places. As a result, the docs' functionality is broken in some places like the language selection not being clickable: Qiskit#272 I wanted to remove jQuery via Qiskit#275, but it is too hard to safely due with Pytorch because we have 105 usages. We will need to wait for the switch to Furo. So, for now, we will include jQuery by default. We also try to activate the extension by default with the line `app.setup_extension("sphinxcontrib.jquery"),` but I'm having issues with that actually working. So, projects may need to still add `"sphinxcontrib.jquery"` explicitly in their extensions in `conf.py` - but they at least won't have to explicitly include `sphinxcontrib-jquery` in their requirements. -- This PR also fixes other issues with our JavaScript, as reported by the developer console: 1. `languages.html` was not recognizing jQuery. So, rewrite it to modern JavaScript 2. `pytorchAnchors.bind();` was not defined so caused some of our setup to fail 3. `handleLeftMenu:` function was failing because `document.getElementById("docs-tutorials-resources")` does not exist. Since that function failed, it looks like it wasn't actually necessary anymore.
…r JavaScript issues (Cherry-pick of #277) (#278) Sphinx 6 stopped including jQuery by default, but we're still using it in some places. As a result, the docs' functionality is broken in some places like the language selection not being clickable: #272 I wanted to remove jQuery via #275, but it is too hard to safely due with Pytorch because we have 105 usages. We will need to wait for the switch to Furo. So, for now, we will include jQuery by default. We also try to activate the extension by default with the line `app.setup_extension("sphinxcontrib.jquery"),` but I'm having issues with that actually working. So, projects may need to still add `"sphinxcontrib.jquery"` explicitly in their extensions in `conf.py` - but they at least won't have to explicitly include `sphinxcontrib-jquery` in their requirements. -- This PR also fixes other issues with our JavaScript, as reported by the developer console: 1. `languages.html` was not recognizing jQuery. So, rewrite it to modern JavaScript 2. `pytorchAnchors.bind();` was not defined so caused some of our setup to fail 3. `handleLeftMenu:` function was failing because `document.getElementById("docs-tutorials-resources")` does not exist. Since that function failed, it looks like it wasn't actually necessary anymore.
I've started to fix some ecosystem projects, like qiskit-community/qiskit-finance#256. The fix isn't complete though: when changing the language, we stop showing what is currently chosen. I suspect this is because versionutils.py is not up-to-date. I will fix this soon. |
@SooluThomas figured out why the Finance docs weren't working when switching to other languages. We weren't properly deploying docs to Everything is now fixed on the The theme release for 1.12 will start including the |
…302) Part of #262. Before, to add translation support, you would have to copy and paste `versionutils.py`. Now, you ~only need to define `translations_list` in `conf.py` and `qiskit_sphinx_theme` will set up the rest for you. That duplication of `versionutils.py` was annoying to copy and also made it too easy to fall out of sync, resulting in #272. To prove this works, this PR removes `language_utils.py` from `example_docs/` and instead sets its values in `conf.py`. Translations still work: <img width="753" alt="Screenshot 2023-05-05 at 1 13 59 PM" src="https://user-images.githubusercontent.com/14852634/236549631-2f844db4-8ff6-49e7-9ef0-af1cbbcb5c43.png"> This PR intentionally does not refactor any of the `translations.py` code. It only copies and pastes what we had from all our projects, to make it easier to review. The only divergences are: * Removing the `translations` config option and HTML context. It wasn't being used by anything. * Removing the `current_translation` HTML context. It wasn't being used by anything.
The language switcher does not work in Runtime documents and Nature documents.
In the other docs, it works fine.
The text was updated successfully, but these errors were encountered: