Skip to content

Commit 85d5a7e

Browse files
epicfaacehugovk
andauthored
bpo-37860: re-add netlify.toml to set up deploy previews for docs (#92852)
* Revert "bpo-46184: remove `netlify.toml` (#30272)" This reverts commit fbaf2e6. * Delete runtime.txt * Create runtime.txt * Delete runtime.txt * Update netlify.toml * Update netlify.toml * Add netlify badge * Update Doc/tools/templates/layout.html Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> * Update layout.html Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
1 parent 5837e5f commit 85d5a7e

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Doc/conf.py

+8
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@
105105
# Short title used e.g. for <title> HTML tags.
106106
html_short_title = '%s Documentation' % release
107107

108+
# Deployment preview information, from Netlify
109+
# (See netlify.toml and https://docs.netlify.com/configure-builds/environment-variables/#git-metadata)
110+
html_context = {
111+
"is_deployment_preview": os.getenv("IS_DEPLOYMENT_PREVIEW"),
112+
"repository_url": os.getenv("REPOSITORY_URL"),
113+
"pr_id": os.getenv("REVIEW_ID")
114+
}
115+
108116
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
109117
# using the given strftime format.
110118
html_last_updated_fmt = '%b %d, %Y'

Doc/tools/templates/layout.html

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
<a href="/3/{{ pagename }}{{ file_suffix }}">{% trans %} Python documentation for the current stable release{% endtrans %}</a>.
99
</div>
1010
{%- endif %}
11+
12+
{%- if is_deployment_preview %}
13+
<div id="deployment-preview-warning" style="padding: .5em; text-align: center; background-color: #fff2ba; color: #6a580e;">
14+
<div style="float: right; margin-top: -10px; margin-left: 10px;">
15+
<a href="https://www.netlify.com">
16+
<img src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg" alt="Deploys by Netlify" />
17+
</a>
18+
</div>
19+
{% trans %}This is a deploy preview created from a <a href="{{ repository_url }}/pull/{{ pr_id }}">pull request</a>.
20+
For authoritative documentation, see the {% endtrans %}
21+
<a href="https://docs.python.org/3/{{ pagename }}{{ file_suffix }}">{% trans %} the current stable release{% endtrans %}</a>.
22+
</div>
23+
{%- endif %}
1124
{% endblock %}
1225

1326
{% block rootrellink %}

netlify.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[build]
2+
base = "Doc/"
3+
command = "make html"
4+
publish = "build/html"
5+
6+
[build.environment]
7+
PYTHON_VERSION = "3.8"
8+
IS_DEPLOYMENT_PREVIEW = "true"

0 commit comments

Comments
 (0)