mirror of
https://github.com/readthedocs/sphinx_rtd_theme.git
synced 2025-02-25 18:55:21 -06:00
Populate html_context
with READTHEDOCS_*
environment variables (#1581)
* Populate `html_context` with `READTHEDOCS_*` environment variables Closes #1578 * Typo
This commit is contained in:
parent
42557430ef
commit
cf898d3acc
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user