]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] Replace Netlify with Read the Docs build previews (#103843) (#104083)
authorHugo van Kemenade <hugovk@users.noreply.github.com>
Tue, 2 May 2023 05:29:27 +0000 (08:29 +0300)
committerGitHub <noreply@github.com>
Tue, 2 May 2023 05:29:27 +0000 (05:29 +0000)
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
.github/workflows/documentation-links.yml [new file with mode: 0644]
.readthedocs.yml [new file with mode: 0644]
Doc/conf.py
Doc/tools/templates/layout.html

diff --git a/.github/workflows/documentation-links.yml b/.github/workflows/documentation-links.yml
new file mode 100644 (file)
index 0000000..43a7afe
--- /dev/null
@@ -0,0 +1,27 @@
+name: Read the Docs PR preview
+# Automatically edits a pull request's descriptions with a link
+# to the documentation's preview on Read the Docs.
+
+on:
+  pull_request_target:
+    types:
+      - opened
+    paths:
+    - 'Doc/**'
+    - '.github/workflows/doc.yml'
+
+permissions:
+  pull-requests: write
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+  cancel-in-progress: true
+
+jobs:
+  documentation-links:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: readthedocs/actions/preview@v1
+        with:
+          project-slug: "cpython-previews"
+          single-version: "true"
diff --git a/.readthedocs.yml b/.readthedocs.yml
new file mode 100644 (file)
index 0000000..898a9ae
--- /dev/null
@@ -0,0 +1,18 @@
+# Read the Docs configuration file
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+# Project page: https://readthedocs.org/projects/cpython-previews/
+
+version: 2
+
+sphinx:
+   configuration: Doc/conf.py
+
+build:
+  os: ubuntu-22.04
+  tools:
+    python: "3"
+
+  commands:
+    - make -C Doc venv html
+    - mkdir _readthedocs
+    - mv Doc/build/html _readthedocs/html
index 216f12dd7ef2aaa71bf2ba563429eefa2de71a1a..138a18409983fcc573e29f0f2f7d35f10e6ed5aa 100644 (file)
@@ -109,6 +109,15 @@ if any('htmlhelp' in arg for arg in sys.argv):
 # Short title used e.g. for <title> HTML tags.
 html_short_title = '%s Documentation' % release
 
+# Deployment preview information
+# (See .readthedocs.yml and https://docs.readthedocs.io/en/stable/reference/environment-variables.html)
+repository_url = os.getenv("READTHEDOCS_GIT_CLONE_URL")
+html_context = {
+    "is_deployment_preview": os.getenv("READTHEDOCS_VERSION_TYPE") == "external",
+    "repository_url": repository_url.removesuffix(".git") if repository_url else None,
+    "pr_id": os.getenv("READTHEDOCS_VERSION")
+}
+
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 # using the given strftime format.
 html_last_updated_fmt = '%b %d, %Y'
index 98ccf4224804b299467414c217837f1551beb110..b91f8138553e623073a84e8012a7b3037d4a06fb 100644 (file)
@@ -8,6 +8,14 @@
     <a href="/3/{{ pagename }}{{ file_suffix }}">{% trans %} Python documentation for the current stable release{% endtrans %}</a>.
 </div>
 {%- endif %}
+
+{%- if is_deployment_preview %}
+<div id="deployment-preview-warning" style="padding: .5em; text-align: center; background-color: #fff2ba; color: #6a580e;">
+  {% trans %}This is a deploy preview created from a <a href="{{ repository_url }}/pull/{{ pr_id }}">pull request</a>.
+  For authoritative documentation, see the {% endtrans %}
+  <a href="https://docs.python.org/3/{{ pagename }}{{ file_suffix }}">{% trans %} the current stable release{% endtrans %}</a>.
+</div>
+{%- endif %}
 {% endblock %}
 
 {% block rootrellink %}