Skip to content

Commit accb417

Browse files
hugovkarhadthedevCAM-Gerlach
authored
Replace Netlify with Read the Docs build previews (python#103843)
Co-authored-by: Oleg Iarygin <dralife@yandex.ru> Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
1 parent 4b10ecc commit accb417

File tree

5 files changed

+51
-21
lines changed

5 files changed

+51
-21
lines changed
+27
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

+18
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

+6-5
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@
114114
# Short title used e.g. for <title> HTML tags.
115115
html_short_title = '%s Documentation' % release
116116

117-
# Deployment preview information, from Netlify
118-
# (See netlify.toml and https://docs.netlify.com/configure-builds/environment-variables/#git-metadata)
117+
# Deployment preview information
118+
# (See .readthedocs.yml and https://docs.readthedocs.io/en/stable/reference/environment-variables.html)
119+
repository_url = os.getenv("READTHEDOCS_GIT_CLONE_URL")
119120
html_context = {
120-
"is_deployment_preview": os.getenv("IS_DEPLOYMENT_PREVIEW"),
121-
"repository_url": os.getenv("REPOSITORY_URL"),
122-
"pr_id": os.getenv("REVIEW_ID")
121+
"is_deployment_preview": os.getenv("READTHEDOCS_VERSION_TYPE") == "external",
122+
"repository_url": repository_url.removesuffix(".git") if repository_url else None,
123+
"pr_id": os.getenv("READTHEDOCS_VERSION")
123124
}
124125

125126
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,

Doc/tools/templates/layout.html

-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111

1212
{%- if is_deployment_preview %}
1313
<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>
1914
{% trans %}This is a deploy preview created from a <a href="{{ repository_url }}/pull/{{ pr_id }}">pull request</a>.
2015
For authoritative documentation, see the {% endtrans %}
2116
<a href="https://docs.python.org/3/{{ pagename }}{{ file_suffix }}">{% trans %} the current stable release{% endtrans %}</a>.

netlify.toml

-11
This file was deleted.

0 commit comments

Comments
 (0)