diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html
index 3df900b9d6..f36e98b402 100644
--- a/docs/_templates/layout.html
+++ b/docs/_templates/layout.html
@@ -157,11 +157,9 @@
- {%- if versions %}
- {%- for tag in versions.tags %}
-
- {%- endfor %}
- {%- endif %}
+ {%- for tag in get_versions() %}
+
+ {%- endfor %}
diff --git a/docs/conf.py b/docs/conf.py
index 231937ab5d..ab9c219623 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -9,8 +9,10 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
+import re
import os
import sys
+from pathlib import Path
from typing import List
sys.path.insert(0, os.path.abspath(".."))
@@ -55,7 +57,7 @@
html_theme = "sphinx_rtd_theme"
html_favicon = "favicon.ico"
html_logo = "logo.jpg"
-html_baseurl = '/ape/'
+html_baseurl = "/ape/"
# 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,
@@ -67,11 +69,11 @@
html_css_files = ["custom.css"]
-def fixpath(p):
+def fixpath(path: str) -> str:
"""
Change paths to reference the resources from 'latest/' to save room.
"""
- suffix = p.split("_static")[1]
+ suffix = path.split("_static")[1]
new = f"/{project}/latest/_static"
if suffix:
@@ -80,6 +82,18 @@ def fixpath(p):
return new
+def get_versions() -> List[str]:
+ build_dir = Path(__file__).parent / "_build" / "ape"
+ if not build_dir.exists():
+ return []
+
+ versions = [
+ d.name for d in build_dir.iterdir() if d.is_dir and re.match(r"v\d+.?\d?.?\d?", d.stem)
+ ]
+ return versions
+
+
html_context = {
"fixpath": fixpath,
+ "get_versions": get_versions,
}