Skip to content

Commit

Permalink
Add navbar version switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
aknierim committed Jul 19, 2023
1 parent 854a84e commit c782ba0
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 3 deletions.
72 changes: 72 additions & 0 deletions docs/_static/switcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[
{
"name": "dev",
"version": "latest",
"url": "https://ctapipe.readthedocs.io/en/latest/"
},
{
"name": "v0.19.2 (stable)",
"version": "stable",
"url": "https://ctapipe.readthedocs.io/en/stable/"
},
{
"name": "v0.19.3",
"version": "v0.19.3",
"url": "https://ctapipe.readthedocs.io/en/v0.19.3/"
},
{
"name": "v0.19.2",
"version": "v0.19.2",
"url": "https://ctapipe.readthedocs.io/en/v0.19.2/"
},
{
"name": "v0.19.1",
"version": "v0.19.1",
"url": "https://ctapipe.readthedocs.io/en/v0.19.1/"
},
{
"name": "v0.19.0",
"version": "v0.19.0",
"url": "https://ctapipe.readthedocs.io/en/v0.19.0/"
},
{
"name": "v0.18.1",
"version": "v0.18.1",
"url": "https://ctapipe.readthedocs.io/en/v0.18.1/"
},
{
"name": "v0.18.0",
"version": "v0.18.0",
"url": "https://ctapipe.readthedocs.io/en/v0.18.0/"
},
{
"name": "v0.17.0",
"version": "v0.17.0",
"url": "https://ctapipe.readthedocs.io/en/v0.17.0/"
},
{
"name": "v0.16.0",
"version": "v0.16.0",
"url": "https://ctapipe.readthedocs.io/en/v0.16.0/"
},
{
"name": "v0.15.0",
"version": "v0.15.0",
"url": "https://ctapipe.readthedocs.io/en/v0.15.0/"
},
{
"name": "v0.14.0",
"version": "v0.14.0",
"url": "https://ctapipe.readthedocs.io/en/v0.14.0/"
},
{
"name": "v0.12.0-rtd",
"version": "v0.12.0-rtd",
"url": "https://ctapipe.readthedocs.io/en/v0.12.0-rtd/"
},
{
"name": "v0.11.0-rtd",
"version": "v0.11.0-rtd",
"url": "https://ctapipe.readthedocs.io/en/v0.11.0-rtd/"
}
]
28 changes: 25 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,26 @@ def setup(app):
todo_include_todos = True


# -- Version switcher -----------------------------------------------------

# Define the json_url for our version switcher.
json_url = "https://ctapipe.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
# If it is an integer, we're in a PR build and the version isn't correct.
if not version_match or version_match.isdigit():
# For local development, infer the version to match from the package.
if "dev" in release or "rc" 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 = release


# -- Options for HTML output ----------------------------------------------

html_theme = "pydata_sphinx_theme"
Expand All @@ -208,7 +228,11 @@ def setup(app):
},
"github_url": "https://github.com/cta-observatory/ctapipe",
"header_links_before_dropdown": 6,
"navbar_start": ["navbar-logo"],
"navbar_start": ["navbar-logo", "version-switcher"],
"switcher": {
"version_match": version_match,
"json_url": json_url,
},
"use_edit_page_button": True,
"icon_links_label": "Quick Links",
"icon_links": [
Expand All @@ -226,8 +250,6 @@ def setup(app):
""",
}

html_sidebars = {"**": ["sidebar-nav-bs.html", "sidebar-ethical-ads.html"]}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
Expand Down

0 comments on commit c782ba0

Please sign in to comment.