Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}``
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Doc/tools/templates/customsourcelink.html
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 %}
Expand Down
Loading