Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate html_context with READTHEDOCS_* environment variables #1581

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sphinx_rtd_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
"""

import os
from os import path
from sys import version_info as python_version

Expand Down Expand Up @@ -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):
Expand Down