Skip to content
Draft
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,18 @@
# a list of builtin themes.
#
html_theme = 'nextstrain-sphinx-theme'

html_theme_options = {
'flyout_display': 'attached',
}

# -- Read the Docs configuration ---------------------------------------------

# Define the canonical URL if you are using a custom domain on Read the Docs
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")

# Tell Jinja2 templates the build is running on Read the Docs
if os.environ.get("READTHEDOCS", "") == "True":
if "html_context" not in globals():
html_context = {}
html_context["READTHEDOCS"] = True
46 changes: 0 additions & 46 deletions lib/nextstrain/sphinx/theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,49 +69,3 @@
{% include "searchbox.html" %}

{% endblock %}


{% block extrabody %}
<!--
Lie about what theme we really are when some RTD-injected JS fetches the
full versions panel from the RTD API. RTD's JS replaces the stub versions
panel in the Sphinx-generated HTML with the full versions panel it fetches
from the RTD API. If the API thinks we're not sphinx_rtd_theme, it will
serve us the wrong HTML and the panel will float as a "badge" when it
shouldn't. As a customized version of sphinx_rtd_theme, we really do want
the same HTML it gets. See also the diagnoses in
<https://github.com/nextstrain/docs.nextstrain.org/issues/76>.

This bit of JS finds the data RTD injects into the page and modifies it
before the code that RTD injects runs and looks at the data. RTD's
<script>s (in <head>) run before this JS, but they wait until the DOM is
ready to actually do any work. This gives us a chance to modify the data
during DOM load before the RTD code actually uses it.

-trs, 27 Jan 2022
-->
<script>
(() => {
try {
console.log("Lying about the theme to RTD's JS so the versions panel works properly. 🙈");

/* Update global variable, which is used in the request to get the RTD
* "footer" that includes the versions panel.
*/
if (window.READTHEDOCS_DATA)
window.READTHEDOCS_DATA.theme = "sphinx_rtd_theme";

/* Update stored JSON in case anything else deserializes it later.
* Comments in the RTD-injected HTML source claim the global variable
* above is deprecated.
*/
var script = document.querySelector("#READTHEDOCS_DATA");
if (script)
script.innerHTML = JSON.stringify({ ...JSON.parse(script.innerHTML), theme: "sphinx_rtd_theme" });
}
catch (err) {
console.log("Lying about the theme to RTD's JS failed… oh well. 🤷", err);
}
})();
</script>
{% endblock %}