From 579b8d3d289d9b9cc3841f9e8a1a1848296235f0 Mon Sep 17 00:00:00 2001
From: Stephan Breimann
Date: Thu, 24 Sep 2026 12:02:34 +0200
Subject: [PATCH] docs(rtd): native version selector for exact releases
Read the Docs Addons already fill the sphinx_rtd_theme (3.0) sidebar version
{% endif %}
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 4a2694060..ffd320687 100755
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -50,6 +50,12 @@
rtd_version = os.environ.get("READTHEDOCS_VERSION", "")
rtd_version_type = os.environ.get("READTHEDOCS_VERSION_TYPE", "")
is_dev_build = rtd_version_type != "tag"
+on_rtd = os.environ.get("READTHEDOCS", "") == "True"
+
+# Canonical URL of the version being built (https://aaanalysis.readthedocs.io/en//).
+# Read the Docs sets it per build; it feeds so search engines
+# and citations resolve to the versioned page. Empty for local builds.
+html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
repository_url = "https://github.com/breimanntools/aaanalysis"
pygments_style = "sphinx"
@@ -166,9 +172,19 @@
# -- Options for HTML output -------------------------------------------------
html_title = "AAanalysis"
html_theme = 'sphinx_rtd_theme'
+# Version selector. sphinx_rtd_theme >= 3.0 no longer draws the version under the
+# logo ("display_version" is gone); instead, on Read the Docs it renders a version
+# in the sidebar header, filled at page-load time from the Read the Docs
+# Addons API with every *active* version (latest, stable, v1.0.0, v1.1.0, ...). The
+# list is therefore native and maintenance-free: activating a release tag in the RTD
+# dashboard (or the automation rule in .readthedocs.yaml) is all a new version needs.
+# "flyout_display": "hidden" keeps the theme from drawing a second, duplicate flyout
+# next to the Read the Docs one in the bottom-right corner.
html_theme_options = {
"logo_only": True,
- "display_version": True,
+ "version_selector": True,
+ "language_selector": False,
+ "flyout_display": "hidden",
"prev_next_buttons_location": "bottom",
"style_external_links": False,
"style_nav_header_background": "#343131",
@@ -180,6 +196,9 @@
}
html_static_path = [os.path.join(path_source, '_static')]
html_css_files = ['css/style.css', 'css/notebook.css']
+# Makes the sidebar version keep the current page when switching versions
+# (the theme links each option to the version root). No-op outside Read the Docs.
+html_js_files = ['js/version_switch.js']
html_show_sphinx = False
html_logo = "_artwork/logos/logo_white_large.png"
html_favicon = "_artwork/logos/favicon_white.svg"
@@ -196,6 +215,12 @@
'aa_release': release,
}
+# The theme gates its Read the Docs integration (the addons tag and the sidebar
+# version selector) on this flag. Read the Docs used to inject it into every Sphinx
+# build; its documentation now asks projects to set it themselves.
+if on_rtd:
+ html_context["READTHEDOCS"] = True
+
html_meta = {
'google-site-verification': 'Rk3T0-H7cpFf5UxXiL4-LMS0WN7FIyU_3NiomozORV0',
'favicon': "_artwork/logos/favicon_white.png"
diff --git a/docs/source/index/CONTRIBUTING_COPY.rst b/docs/source/index/CONTRIBUTING_COPY.rst
index fcd2aa1dd..e310d4e0f 100644
--- a/docs/source/index/CONTRIBUTING_COPY.rst
+++ b/docs/source/index/CONTRIBUTING_COPY.rst
@@ -521,6 +521,13 @@ To cut a release:
Description: the release_notes / CHANGELOG entry for this version
-> Publish release
+ The new tag also becomes a documentation version: a Read the Docs automation rule
+ (``^v\d+\.\d+\.\d+$`` -> *Activate version*, see ``.readthedocs.yaml``) activates
+ and builds it, so https://aaanalysis.readthedocs.io/en/vX.Y.Z/ appears in the
+ version selector and ``stable`` moves to it. Check that the tag's build is green
+ on https://app.readthedocs.org/projects/aaanalysis/builds/ ; a tag is built from
+ its own commit, so a red build there cannot be fixed from ``master``.
+
5. **Verify the upload.**
Confirm the version, files and metadata on https://pypi.org/project/aaanalysis/ ,
diff --git a/docs/source/index/citations.rst b/docs/source/index/citations.rst
index 079bc7286..cc7d7052e 100755
--- a/docs/source/index/citations.rst
+++ b/docs/source/index/citations.rst
@@ -21,3 +21,12 @@ If you use **AAanalysis** in your work, please cite the respective publication a
[Breimann25]_ Breimann and Kamp *et al.* (2025),
*Charting γ-secretase substrates by explainable AI*,
`Nature Communications `__.
+
+**Documentation for an exact release**: the version selector in the sidebar lists every
+release, and each one has a permanent URL of the form
+``https://aaanalysis.readthedocs.io/en/vX.Y.Z/`` (for example
+`v1.0.0 `__). Those pages are built once from
+the release tag and do not change when newer versions are published, so cite them when a
+result depends on a specific AAanalysis version. By contrast,
+`stable `__ always tracks the newest release
+and `latest `__ the development branch.