summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-05-04 21:46:14 +0200
committerGitHub <noreply@github.com>2022-05-04 16:46:14 -0300
commit4c3958b98913e6d77c751cd4556efbb27e43c446 (patch)
tree69c050ff37c1ddcb1adc3eaccc229a992245ecc8 /doc/source
parentc62930f9ec6de9d03e8622c344bbdadece2b1af7 (diff)
downloadnumpy-4c3958b98913e6d77c751cd4556efbb27e43c446.tar.gz
DOC: Add version switcher to the documentation (#21426)
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/_static/versions.json62
-rw-r--r--doc/source/conf.py12
2 files changed, 74 insertions, 0 deletions
diff --git a/doc/source/_static/versions.json b/doc/source/_static/versions.json
new file mode 100644
index 000000000..104a30de7
--- /dev/null
+++ b/doc/source/_static/versions.json
@@ -0,0 +1,62 @@
+[
+ {
+ "name": "dev",
+ "version": "devdocs",
+ "url": "https://numpy.org/devdocs/"
+ },
+ {
+ "name": "1.22 (stable)",
+ "version": "stable",
+ "url": "https://numpy.org/doc/stable/"
+ },
+ {
+ "name": "1.22",
+ "version": "1.22",
+ "url": "https://numpy.org/doc/1.22/"
+ },
+ {
+ "name": "1.21",
+ "version": "1.21",
+ "url": "https://numpy.org/doc/1.21/"
+ },
+ {
+ "name": "1.20",
+ "version": "1.20",
+ "url": "https://numpy.org/doc/1.20/"
+ },
+ {
+ "name": "1.19",
+ "version": "1.19",
+ "url": "https://numpy.org/doc/1.19/"
+ },
+ {
+ "name": "1.18",
+ "version": "1.18",
+ "url": "https://numpy.org/doc/1.18/"
+ },
+ {
+ "name": "1.17",
+ "version": "1.17",
+ "url": "https://numpy.org/doc/1.17/"
+ },
+ {
+ "name": "1.16",
+ "version": "1.16",
+ "url": "https://numpy.org/doc/1.16/"
+ },
+ {
+ "name": "1.15",
+ "version": "1.15",
+ "url": "https://numpy.org/doc/1.15/"
+ },
+ {
+ "name": "1.14",
+ "version": "1.14",
+ "url": "https://numpy.org/doc/1.14/"
+ },
+ {
+ "name": "1.13",
+ "version": "1.13",
+ "url": "https://numpy.org/doc/1.13/"
+ }
+]
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 4301fe553..1a201a3c5 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -171,6 +171,12 @@ html_logo = '_static/numpylogo.svg'
html_favicon = '_static/favicon/favicon.ico'
+# Set up the version switcher. The versions.json is stored in the devdocs.
+if ".dev" in version:
+ switcher_version = "devdocs"
+else:
+ switcher_version = f"doc/{version}"
+
html_theme_options = {
"logo_link": "index",
"github_url": "https://github.com/numpy/numpy",
@@ -179,6 +185,12 @@ html_theme_options = {
"external_links": [
{"name": "Learn", "url": "https://numpy.org/numpy-tutorials/"}
],
+ # Add light/dark mode and documentation version switcher:
+ "navbar_end": ["version-switcher", "navbar-icon-links"],
+ "switcher": {
+ "version_match": switcher_version,
+ "json_url": "https://numpy.org/devdocs/_static/versions.json",
+ },
}
html_title = "%s v%s Manual" % (project, version)