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

Allow relative json url to work locally (and hopefully on PRs) #599

Merged
merged 2 commits into from
Mar 5, 2022
Merged
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
9 changes: 7 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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