https://github.com/python/cpython/commit/6f88e6d16c5d2a51b3ee27a552607c7e17200c0b commit: 6f88e6d16c5d2a51b3ee27a552607c7e17200c0b branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: hugovk <[email protected]> date: 2026-09-15T16:02:55Z summary:
[3.14] gh-157517: Don't copy HTML sources and fix sidebar sources links in docs builds (GH-157522) (#157568) 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 79b8d91ffd8b3cc..4e32088658c0b57 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -77,6 +77,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}`` @@ -301,6 +303,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. @@ -310,6 +313,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 @@ -571,9 +577,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]
