Skip to content

Commit

Permalink
Allow relative json url to work locally (and hopefully on PRs) (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
damianavila committed Mar 5, 2022
1 parent 8785747 commit 3ebd74f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions docs/conf.py
Expand Up @@ -78,6 +78,9 @@
html_theme = "pydata_sphinx_theme"
# html_logo = "_static/pandas.svg" # For testing

# Define the json_url for our version switcher.
json_url = "https://pydata-sphinx-theme.readthedocs.io/en/latest/_static/switcher.json"

# Define the version we use for matching in the version switcher.
version_match = os.environ.get("READTHEDOCS_VERSION")
# If READTHEDOCS_VERSION doesn't exist, we're not on RTD
Expand All @@ -87,6 +90,9 @@
release = pydata_sphinx_theme.__version__
if "dev" in release:
version_match = "latest"
# We want to keep the relative reference if we are in dev mode
# but we want the whole url if we are effectively in a released version
json_url = "/_static/switcher.json"
else:
version_match = "v" + release

Expand Down Expand Up @@ -124,8 +130,7 @@
# "left_sidebar_end": ["custom-template.html", "sidebar-ethical-ads.html"],
# "footer_items": ["copyright", "sphinx-version", ""]
"switcher": {
# "json_url": "/_static/switcher.json",
"json_url": "https://pydata-sphinx-theme.readthedocs.io/en/latest/_static/switcher.json",
"json_url": json_url,
"url_template": "https://pydata-sphinx-theme.readthedocs.io/en/{version}/",
"version_match": version_match,
},
Expand Down
Expand Up @@ -76,7 +76,7 @@
$("#version_switcher_button").text(entry.name);
// Add extra class to the button for the selected entry
if ("extra_classes" in entry) {
$("#version_switcher_menu").classList.add(...entry.extra_classes);
$("#version_switcher_menu")[0].classList.add(...entry.extra_classes);
}
}
});
Expand Down

0 comments on commit 3ebd74f

Please sign in to comment.