Skip to content

Commit

Permalink
Merge pull request #571 from GAA-UAM/feature/web_version_switcher
Browse files Browse the repository at this point in the history
Add a version switcher for the docs in the web.
  • Loading branch information
vnmabus committed Sep 20, 2023
2 parents 55a7e99 + 2edf515 commit 3980c53
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
13 changes: 13 additions & 0 deletions docs/_static/switcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"name": "dev",
"version": "dev",
"url": "https://fda.readthedocs.io/en/latest/"
},
{
"name": "0.8.1 (stable)",
"version": "stable",
"url": "https://fda.readthedocs.io/en/stable/",
"preferred": true
}
]
24 changes: 20 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@
"Universidad Autónoma de Madrid"
)
github_url = "https://github.com/GAA-UAM/scikit-fda"
rtd_version = os.environ.get("READTHEDOCS_VERSION", "latest")
branch = "master" if rtd_version == "stable" else "develop"
rtd_version = os.environ.get("READTHEDOCS_VERSION")
rtd_version_type = os.environ.get("READTHEDOCS_VERSION_TYPE")

switcher_version = rtd_version
if switcher_version == "latest":
switcher_version = "dev"
elif rtd_version_type not in {"branch", "tag"}:
switcher_version = skfda.__version__

rtd_branch = os.environ.get(" READTHEDOCS_GIT_IDENTIFIER", "develop")
language = "en"

try:
Expand Down Expand Up @@ -112,6 +120,14 @@
html_theme_options = {
"use_edit_page_button": True,
"github_url": github_url,
"switcher": {
"json_url": (
"https://fda.readthedocs.io/en/latest/_static/switcher.json"
),
"version_match": switcher_version,
},
"show_version_warning_banner": True,
"navbar_start": ["navbar-logo", "version-switcher"],
"icon_links": [
{
"name": "PyPI",
Expand Down Expand Up @@ -289,7 +305,7 @@ def linkcode_resolve(domain: str, info: Mapping[str, str]) -> str | None:
else:
linespec = ""

return f"{github_url}/tree/{branch}/skfda/{fn}{linespec}"
return f"{github_url}/tree/{rtd_branch}/skfda/{fn}{linespec}"

# -- Options for "sphinx.ext.mathjax" --

Expand Down Expand Up @@ -391,7 +407,7 @@ def __repr__(self) -> str:
"binder": {
"org": "GAA-UAM",
"repo": "scikit-fda",
"branch": branch,
"branch": rtd_branch,
"binderhub_url": "https://mybinder.org",
"dependencies": ["../binder/requirements.txt"],
"notebooks_dir": "../examples",
Expand Down

0 comments on commit 3980c53

Please sign in to comment.