https://github.com/python/cpython/commit/362839671e2a75bee291b1cfd0061b08533678e6
commit: 362839671e2a75bee291b1cfd0061b08533678e6
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2026-09-15T16:02:16Z
summary:

[3.15] gh-157517: Don't copy HTML sources and fix sidebar sources links in docs 
builds (GH-157522) (#157567)

Co-authored-by: Maciej Olko <[email protected]>
Co-authored-by: Stan Ulbrych <[email protected]>

files:
M Doc/conf.py
M Doc/tools/templates/customsourcelink.html

diff --git a/Doc/conf.py b/Doc/conf.py
index 0c6e7cfa9c9bc43..91888fa9838c364 100644
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -78,6 +78,8 @@
 # and replace the values accordingly.
 # See Doc/tools/extensions/patchlevel.py
 version, release = get_version_info()
+v = get_header_version_info()
+branch = "main" if v.releaselevel == "alpha" else f"{v.major}.{v.minor}"
 
 rst_epilog = f"""
 .. |python_version_literal| replace:: ``Python {version}``
@@ -298,6 +300,7 @@
     "repository_url": repository_url or None,
     "pr_id": os.getenv("READTHEDOCS_VERSION"),
     "enable_analytics": os.getenv("PYTHON_DOCS_ENABLE_ANALYTICS"),
+    "source_branch": branch,
 }
 
 # This 'Last updated on:' timestamp is inserted at the bottom of every page.
@@ -307,6 +310,9 @@
 # Path to find HTML templates to override theme
 templates_path = ['tools/templates']
 
+# We link to sources on GitHub, so don't copy them into the HTML output.
+html_copy_source = False
+
 # Custom sidebar templates, filenames relative to this file.
 html_sidebars = {
     # Defaults taken from 
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_sidebars
@@ -573,9 +579,6 @@
 # Options for sphinx.ext.extlinks
 # -------------------------------
 
-v = get_header_version_info()
-branch = "main" if v.releaselevel == "alpha" else f"{v.major}.{v.minor}"
-
 # This config is a dictionary of external sites,
 # mapping unique short aliases to a base URL and a prefix.
 # https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
diff --git a/Doc/tools/templates/customsourcelink.html 
b/Doc/tools/templates/customsourcelink.html
index 8feeed2fee3650a..eb194aa038c1bef 100644
--- a/Doc/tools/templates/customsourcelink.html
+++ b/Doc/tools/templates/customsourcelink.html
@@ -1,4 +1,4 @@
-{%- if show_source and has_source and sourcename %}
+{%- if page_source_suffix is defined %}
   <script>
     document.addEventListener('DOMContentLoaded', () => {
         const title = 
document.querySelector('meta[property="og:title"]').content;
@@ -19,13 +19,13 @@ <h3>{{ _('This page') }}</h3>
       <li><a href="{{ pathto('bugs') }}">{% trans %}Report a bug{% endtrans 
%}</a></li>
       <li><a class="improvepage" href="{{ pathto('improve-page-nojs') }}">{% 
trans %}Improve this page{% endtrans %}</a></li>
       <li>
-        <a href="https://github.com/python/cpython/blob/main/Doc/{{ pagename 
}}.rst?plain=1"
+        <a href="https://github.com/python/cpython/blob/{{ source_branch 
}}/Doc/{{ pagename }}.rst?plain=1"
             rel="nofollow">{{ _('Show source') }}
         </a>
       </li>
-      {% if language != "en" %}
+      {% if language != "en" and source_branch != "main" %}
       <li>
-        <a href="https://github.com/python/python-docs-{{ language }}/blob/{{ 
version }}/{{ pagename }}.po?plain=1"
+        <a href="https://github.com/python/python-docs-{{ language | 
replace('_', '-') | lower }}/blob/{{ source_branch }}/{{ pagename }}.po?plain=1"
            rel="nofollow">{{ _('Show translation source') }}</a>
       </li>
       {% endif %}

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to