Skip to content

Commit cbfdc9f

Browse files
committed
Add version switcher in documentation
1 parent d7e6fd0 commit cbfdc9f

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

doc/source/_static/switcher.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"name": "dev",
4+
"version": "latest"
5+
},
6+
{
7+
"name": "0.1.0",
8+
"version": "v0.1.0"
9+
}
10+
]

doc/source/conf.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
'astropy': ('https://docs.astropy.org/en/stable/', None)
5353
}
5454

55+
import watts
56+
version = release = watts.__version__
57+
5558
# -- Options for HTML output -------------------------------------------------
5659

5760
# The theme to use for HTML and HTML Help pages. See the documentation for
@@ -65,16 +68,15 @@
6568

6669
html_theme = 'pydata_sphinx_theme'
6770

68-
html_theme_options = {
69-
'github_url': 'https://github.com/watts-dev/watts',
70-
}
71-
7271
# Add any paths that contain custom static files (such as style sheets) here,
7372
# relative to this directory. They are copied after the builtin static files,
7473
# so a file named "default.css" will overwrite the builtin "default.css".
7574
html_static_path = ['_static']
75+
7676
html_logo = '_static/watts.svg'
77+
7778
html_theme_options = {
79+
"github_url": "https://github.com/watts-dev/watts",
7880
"favicons": [
7981
{
8082
"rel": "icon",
@@ -86,5 +88,11 @@
8688
"sizes": "32x32",
8789
"href": "watts_32x32.png",
8890
},
89-
]
91+
],
92+
"switcher": {
93+
"json_url": "https://watts.readthedocs.io/en/latest/_static/switcher.json",
94+
"url_template": "https://watts.readthedocs.io/en/{version}/",
95+
"version_match": version if '-dev' not in version else 'dev',
96+
},
97+
"navbar_end": ["version-switcher", "navbar-icon-links"]
9098
}

0 commit comments

Comments
 (0)