From bedfcdcf191b1b9ea5ce0df41e7b6e550a749521 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Wed, 2 Mar 2022 14:00:44 +0100 Subject: [PATCH] Generate docs for stable and develop --- docs/_templates/layout.html | 16 ++++++++++++++++ docs/_templates/versions.html | 19 +++++++++++++++++++ docs/build_docs.sh | 2 +- docs/conf.py | 27 ++++++++++++++++++++------- 4 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 docs/_templates/layout.html create mode 100644 docs/_templates/versions.html 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" %} +
+

Warning

+

This documentation only applies for the development version of + Funkwhale! Visit the docs for the latest + release.

+
+ {% 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 355eea6d5..7ba31a7b4 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")) @@ -46,8 +46,20 @@ for key, value in FUNKWHALE_CONFIG.items(): # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["sphinx.ext.graphviz", "sphinx.ext.autodoc"] -autodoc_mock_imports = ["celery", "django_auth_ldap", "ldap", "persisting_theory", "rest_framework"] +extensions = [ + "sphinx.ext.graphviz", + "sphinx.ext.autodoc", + "myst_parser", + "sphinx_panels", + "sphinx_multiversion", +] +autodoc_mock_imports = [ + "celery", + "django_auth_ldap", + "ldap", + "persisting_theory", + "rest_framework", +] add_module_names = False # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] @@ -72,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 @@ -230,3 +239,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)$"