Skip to content

Commit fd548ce

Browse files
committed
add version switcher
1 parent 56553c9 commit fd548ce

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

doc/_static/switcher.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"name": "dev",
4+
"version": "latest",
5+
"url": "https://docs.doubleml.org/dev/"
6+
},
7+
{
8+
"name": "0.5.2 (stable)",
9+
"version": "stable",
10+
"url": "https://docs.doubleml.org/stable/"
11+
}
12+
]

doc/conf.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import sys
1515
sys.path.insert(0, os.path.abspath('..'))
1616

17+
import doubleml
18+
1719

1820
# -- Project information -----------------------------------------------------
1921

@@ -69,15 +71,38 @@
6971
#
7072
html_theme = 'pydata_sphinx_theme'
7173

74+
# html_logo = '../img/logo.png'
75+
html_extra_path = ['../img/logo.png']
76+
html_favicon = '../img/favicon.ico'
77+
78+
# Define the json_url for our version switcher.
79+
json_url = 'https://docs.doubleml.org/stable/_static/switcher.json'
80+
81+
# Define the version we use for matching in the version switcher.
82+
version_match = os.environ.get("READTHEDOCS_VERSION")
83+
# If READTHEDOCS_VERSION doesn't exist, we're not on RTD
84+
# If it is an integer, we're in a PR build and the version isn't correct.
85+
if not version_match or version_match.isdigit():
86+
# For local development, infer the version to match from the package.
87+
release = doubleml.__version__
88+
if "dev" in release or "rc" in release:
89+
version_match = "latest"
90+
# We want to keep the relative reference if we are in dev mode
91+
# but we want the whole url if we are effectively in a released version
92+
json_url = "_static/switcher.json"
93+
else:
94+
version_match = "v" + release
95+
7296
html_theme_options = {
97+
"navbar_start": ["navbar-logo", "version-switcher"],
7398
'github_url': 'https://github.com/DoubleML/doubleml-for-py',
7499
'navigation_with_keys': False,
100+
'switcher': {
101+
'json_url': json_url,
102+
'version_match': version_match,
103+
}
75104
}
76105

77-
# html_logo = '../img/logo.png'
78-
html_extra_path = ['../img/logo.png']
79-
html_favicon = '../img/favicon.ico'
80-
81106
html_sidebars = {'**': ['logo.html',
82107
'search-field.html',
83108
'sidebar-nav-bs.html'],

0 commit comments

Comments
 (0)