diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html
new file mode 100644
index 000000000..66f450931
--- /dev/null
+++ b/docs/_templates/layout.html
@@ -0,0 +1,16 @@
+{% extends "!layout.html" %}
+
+{% block document %}
+
+ {% if current_version.name == "develop" %}
+
+ {% endif %}
+
+{{ super() }}
+
+{% endblock %}
diff --git a/docs/_templates/versions.html b/docs/_templates/versions.html
new file mode 100644
index 000000000..5f38020b9
--- /dev/null
+++ b/docs/_templates/versions.html
@@ -0,0 +1,19 @@
+{%- if current_version %}
+
+
+ Other Versions
+ {{ current_version.name }}
+
+
+
+ {%- if versions.branches %}
+
+ - Versions
+ {%- for item in versions.branches %}
+ - {{ item.name }}
+ {%- endfor %}
+
+ {%- endif %}
+
+
+{%- endif %}
diff --git a/docs/build_docs.sh b/docs/build_docs.sh
index 6a3354496..4fb40928f 100755
--- a/docs/build_docs.sh
+++ b/docs/build_docs.sh
@@ -1,6 +1,6 @@
#!/bin/bash -eux
# Building sphinx and swagger docs
-python -m sphinx . $BUILD_PATH
+poetry run sphinx-multiversion . $BUILD_PATH
TARGET_PATH="$BUILD_PATH/swagger" ./build_swagger.sh
python ./get-releases-json.py > $BUILD_PATH/releases.json
python ./get-releases-json.py --latest > $BUILD_PATH/latest.txt
diff --git a/docs/conf.py b/docs/conf.py
index 4fcae0e76..95dc2bbad 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -20,7 +20,7 @@
import os
import sys
import datetime
-from shutil import copyfile
+import subprocess
sys.path.insert(0, os.path.abspath("../api"))
sys.path.insert(0, os.path.abspath("../api/config"))
@@ -51,6 +51,7 @@ extensions = [
"sphinx.ext.autodoc",
"myst_parser",
"sphinx_panels",
+ "sphinx_multiversion",
]
autodoc_mock_imports = [
"celery",
@@ -83,10 +84,7 @@ author = "The Funkwhale Collective"
# built documents.
#
# The short X.Y version.
-version = funkwhale_api.__version__
-if "-dev" in version:
- version = "develop"
-# The full version, including alpha/beta/rc tags.
+version = subprocess.check_output(["git", "describe", "--tags"]).strip().decode("utf-8")
release = version
# The language for content autogenerated by Sphinx. Refer to documentation
@@ -267,3 +265,7 @@ def copy_legacy_redirects(app, docname):
def setup(app):
app.connect("build-finished", copy_legacy_redirects)
+
+
+smv_tag_whitelist = None
+smv_branch_whitelist = r"(stable|develop)$"