https://github.com/python/cpython/commit/62dff00e3af061e66bad3f38afce33c7cfc8eb91 commit: 62dff00e3af061e66bad3f38afce33c7cfc8eb91 branch: 3.13 author: Stan Ulbrych <[email protected]> committer: StanFromIreland <[email protected]> date: 2026-09-15T16:23:07Z summary:
[3.13] gh-157517: Don't copy HTML sources and fix sidebar sources links in docs builds (GH-157522) (#157570) (cherry picked from commit 5601e1ec3b5b4b94f189f8a457eea445cda6be45) Co-authored-by: Maciej Olko <[email protected]> files: M Doc/conf.py M Doc/tools/templates/customsourcelink.html diff --git a/Doc/conf.py b/Doc/conf.py index 8a2dd8a8e17af0..677f948efa5104 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -76,6 +76,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}`` @@ -294,6 +296,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. @@ -303,6 +306,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 @@ -564,9 +570,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 0d83ac9f78adb9..4ef373c1dd6c39 100644 --- a/Doc/tools/templates/customsourcelink.html +++ b/Doc/tools/templates/customsourcelink.html @@ -1,16 +1,16 @@ -{%- if show_source and has_source and sourcename %} +{%- if page_source_suffix is defined %} <div role="note" aria-label="source link"> <h3>{{ _('This page') }}</h3> <ul class="this-page-menu"> <li><a href="{{ pathto('bugs') }}">{% trans %}Report a bug{% endtrans %}</a></li> <li> - <a href="https://github.com/python/cpython/blob/main/Doc/{{ sourcename|replace('.rst.txt', '.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]
