Populate html_context with READTHEDOCS_* environment variables (#1581)

* Populate `html_context` with `READTHEDOCS_*` environment variables

Closes #1578

* Typo
This commit is contained in:
Manuel Kaufmann 2024-08-01 19:18:37 +02:00 committed by GitHub
parent 42557430ef
commit cf898d3acc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ Sphinx Read the Docs theme.
From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
"""
import os
from os import path
from sys import version_info as python_version
@ -36,6 +37,15 @@ def extend_html_context(app, pagename, templatename, context, doctree):
# Add ``sphinx_version_info`` tuple for use in Jinja templates
context['sphinx_version_info'] = sphinx_version
# Inject all the Read the Docs environment variables in the context:
# https://docs.readthedocs.io/en/stable/reference/environment-variables.html
context['READTHEDOCS'] = os.environ.get("READTHEDOCS", False) == "True"
if context['READTHEDOCS']:
for key, value in os.environ.items():
if key.startswith("READTHEDOCS_"):
context[key] = value
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
def setup(app):