diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index ef51e4e81..0bef34d85 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -4,7 +4,10 @@ Changelog ========= -.. ifconfig:: include_changelog_staging +.. ifconfig:: build_type == 'latest' + + .. warning:: + This is a documentation build for an unreleased version of pypdfium2, so it is possible that new changes are not logged yet. Next ---- diff --git a/docs/source/conf.py b/docs/source/conf.py index 066528f8c..007bbbe66 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,7 +3,9 @@ # Configuration file for the Sphinx documentation builder. # See https://www.sphinx-doc.org/en/master/usage/configuration.html +# and https://docs.readthedocs.io/en/stable/environment-variables.html +import os import sys import time from os.path import ( @@ -14,17 +16,27 @@ sys.path.insert(0, join(dirname(dirname(dirname(abspath(__file__)))), "setupsrc")) from pl_setup.packaging_base import ( - get_changelog_staging, + run_cmd, + SourceTree, ) -def _have_changelog(): - log = get_changelog_staging() - if log: - return True + +def _get_build_type(): + + # RTD uses git checkout --force origin/... which results in a detached HEAD state, so we cannot easily get the branch name + # Thus query for an RTD-specific environment variable instead + rtd_version_name = os.environ.get("READTHEDOCS_VERSION_NAME", None) + if rtd_version_name: + return rtd_version_name + + branch = run_cmd(["git", "branch", "--show-current"], cwd=SourceTree, capture=True) + if branch == "stable": + return "stable" else: - return False + return "latest" + -include_changelog_staging = _have_changelog() +build_type = _get_build_type() project = "pypdfium2" author = "pypdfium2-team" @@ -68,4 +80,4 @@ def _have_changelog(): def setup(app): - app.add_config_value("include_changelog_staging", False, "env") + app.add_config_value("build_type", "latest", "env")