From cc52dca02fdfc5c7fe1f48dc1c378daf6905197f Mon Sep 17 00:00:00 2001 From: tkknight <2108488+tkknight@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:13:15 +0100 Subject: [PATCH] moved latest warning banner logic to conf.py (#5508) --- docs/src/_templates/layout.html | 20 -------------------- docs/src/conf.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 20 deletions(-) delete mode 100644 docs/src/_templates/layout.html diff --git a/docs/src/_templates/layout.html b/docs/src/_templates/layout.html deleted file mode 100644 index 974bd12753..0000000000 --- a/docs/src/_templates/layout.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "pydata_sphinx_theme/layout.html" %} - -{# This uses blocks. See: - https://www.sphinx-doc.org/en/master/templating.html -#} - - - {%- block docs_body %} - - {% if on_rtd and rtd_version == 'latest' %} -
- You are viewing the latest unreleased documentation - v{{ version }}. You can switch to a stable version - via the flyout menu in the bottom corner of the screen. -
-

- {%- endif %} - - {{ super() }} -{%- endblock %} diff --git a/docs/src/conf.py b/docs/src/conf.py index 72f2ebf4ff..17a0d621cb 100644 --- a/docs/src/conf.py +++ b/docs/src/conf.py @@ -331,6 +331,16 @@ def _dotv(version): }, } +# if we are building via Read The Docs and it is the latest (not stable) +if on_rtd and rtd_version == "latest": + html_theme_options[ + "announcement" + ] = f""" + You are viewing the latest unreleased documentation + {version}. You can switch to a + stable + version.""" + rev_parse = run(["git", "rev-parse", "--short", "HEAD"], capture_output=True) commit_sha = rev_parse.stdout.decode().strip()