Skip to content

Commit 06321b8

Browse files
committed
Fix sources links
Hide translation links on dev version.
1 parent 8fca439 commit 06321b8

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Doc/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
# and replace the values accordingly.
7878
# See Doc/tools/extensions/patchlevel.py
7979
version, release = get_version_info()
80+
v = get_header_version_info()
81+
branch = "main" if v.releaselevel == "alpha" else f"{v.major}.{v.minor}"
8082

8183
rst_epilog = f"""
8284
.. |python_version_literal| replace:: ``Python {version}``
@@ -297,6 +299,7 @@
297299
"repository_url": repository_url or None,
298300
"pr_id": os.getenv("READTHEDOCS_VERSION"),
299301
"enable_analytics": os.getenv("PYTHON_DOCS_ENABLE_ANALYTICS"),
302+
"source_branch": branch,
300303
}
301304

302305
# This 'Last updated on:' timestamp is inserted at the bottom of every page.
@@ -560,9 +563,6 @@
560563
# Options for sphinx.ext.extlinks
561564
# -------------------------------
562565

563-
v = get_header_version_info()
564-
branch = "main" if v.releaselevel == "alpha" else f"{v.major}.{v.minor}"
565-
566566
# This config is a dictionary of external sites,
567567
# mapping unique short aliases to a base URL and a prefix.
568568
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html

Doc/tools/templates/customsourcelink.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ <h3>{{ _('This page') }}</h3>
1919
<li><a href="{{ pathto('bugs') }}">{% trans %}Report a bug{% endtrans %}</a></li>
2020
<li><a class="improvepage" href="{{ pathto('improve-page-nojs') }}">{% trans %}Improve this page{% endtrans %}</a></li>
2121
<li>
22-
<a href="https://github.com/python/cpython/blob/main/Doc/{{ pagename }}.rst?plain=1"
22+
<a href="https://github.com/python/cpython/blob/{{ source_branch }}/Doc/{{ pagename }}.rst?plain=1"
2323
rel="nofollow">{{ _('Show source') }}
2424
</a>
2525
</li>
26-
{% if language != "en" %}
26+
{% if language != "en" and source_branch != "main" %}
2727
<li>
28-
<a href="https://github.com/python/python-docs-{{ language }}/blob/{{ version }}/{{ pagename }}.po?plain=1"
28+
<a href="https://github.com/python/python-docs-{{ language | replace('_', '-') | lower }}/blob/{{ source_branch }}/{{ pagename }}.po?plain=1"
2929
rel="nofollow">{{ _('Show translation source') }}</a>
3030
</li>
3131
{% endif %}

0 commit comments

Comments
 (0)