Skip to content

Commit a821a18

Browse files
hugovkarhadthedevCAM-Gerlach
committed
Replace Netlify with Read the Docs build previews (python#103843)
Co-authored-by: Oleg Iarygin <[email protected]> Co-authored-by: C.A.M. Gerlach <[email protected]> (cherry picked from commit accb417)
1 parent 9f191a1 commit a821a18

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Read the Docs PR preview
2+
# Automatically edits a pull request's descriptions with a link
3+
# to the documentation's preview on Read the Docs.
4+
5+
on:
6+
pull_request_target:
7+
types:
8+
- opened
9+
paths:
10+
- 'Doc/**'
11+
- '.github/workflows/doc.yml'
12+
13+
permissions:
14+
pull-requests: write
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
documentation-links:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: readthedocs/actions/preview@v1
25+
with:
26+
project-slug: "cpython-previews"
27+
single-version: "true"

.readthedocs.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
# Project page: https://readthedocs.org/projects/cpython-previews/
4+
5+
version: 2
6+
7+
sphinx:
8+
configuration: Doc/conf.py
9+
10+
build:
11+
os: ubuntu-22.04
12+
tools:
13+
python: "3"
14+
15+
commands:
16+
- make -C Doc venv html
17+
- mkdir _readthedocs
18+
- mv Doc/build/html _readthedocs/html

Doc/conf.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@
109109
# Short title used e.g. for <title> HTML tags.
110110
html_short_title = '%s Documentation' % release
111111

112+
# Deployment preview information
113+
# (See .readthedocs.yml and https://docs.readthedocs.io/en/stable/reference/environment-variables.html)
114+
repository_url = os.getenv("READTHEDOCS_GIT_CLONE_URL")
115+
html_context = {
116+
"is_deployment_preview": os.getenv("READTHEDOCS_VERSION_TYPE") == "external",
117+
"repository_url": repository_url.removesuffix(".git") if repository_url else None,
118+
"pr_id": os.getenv("READTHEDOCS_VERSION")
119+
}
120+
112121
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
113122
# using the given strftime format.
114123
html_last_updated_fmt = '%b %d, %Y'

Doc/tools/templates/layout.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
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+
{% trans %}This is a deploy preview created from a <a href="{{ repository_url }}/pull/{{ pr_id }}">pull request</a>.
15+
For authoritative documentation, see the {% endtrans %}
16+
<a href="https://docs.python.org/3/{{ pagename }}{{ file_suffix }}">{% trans %} the current stable release{% endtrans %}</a>.
17+
</div>
18+
{%- endif %}
1119
{% endblock %}
1220

1321
{% block rootrellink %}

0 commit comments

Comments
 (0)