Skip to content

Commit 99cfb11

Browse files
committed
[3.15] Docs: Replace hardcoded SOURCE_URI with patchlevel check (GH-150850)
(cherry picked from commit b643826) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 21a4ac7 commit 99cfb11

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

Doc/conf.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88

99
import os
1010
import sys
11-
from importlib import import_module
1211
from importlib.util import find_spec
1312

1413
# Make our custom extensions available to Sphinx
1514
sys.path.append(os.path.abspath('tools/extensions'))
1615
sys.path.append(os.path.abspath('includes'))
1716

18-
# Python specific content from Doc/Tools/extensions/pyspecific.py
19-
from pyspecific import SOURCE_URI
17+
from patchlevel import get_header_version_info, get_version_info
2018

2119
# General configuration
2220
# ---------------------
@@ -78,7 +76,7 @@
7876
# We look for the Include/patchlevel.h file in the current Python source tree
7977
# and replace the values accordingly.
8078
# See Doc/tools/extensions/patchlevel.py
81-
version, release = import_module('patchlevel').get_version_info()
79+
version, release = get_version_info()
8280

8381
rst_epilog = f"""
8482
.. |python_version_literal| replace:: ``Python {version}``
@@ -557,16 +555,20 @@
557555
r'https://unix.org/version2/whatsnew/lp64_wp.html',
558556
]
559557

558+
560559
# Options for sphinx.ext.extlinks
561560
# -------------------------------
562561

562+
v = get_header_version_info()
563+
branch = "main" if v.releaselevel == "alpha" else f"{v.major}.{v.minor}"
564+
563565
# This config is a dictionary of external sites,
564566
# mapping unique short aliases to a base URL and a prefix.
565567
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
566568
extlinks = {
567569
"oss-fuzz": ("https://issues.oss-fuzz.com/issues/%s", "#%s"),
568570
"pypi": ("https://pypi.org/project/%s/", "%s"),
569-
"source": (SOURCE_URI, "%s"),
571+
"source": (f"https://github.com/python/cpython/tree/{branch}/%s", "%s"),
570572
}
571573
extlinks_detect_hardcoded_links = True
572574

Doc/tools/extensions/pyspecific.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,10 @@
1010
"""
1111

1212
import re
13-
import io
14-
from os import getenv, path
1513

16-
from docutils import nodes
17-
from docutils.parsers.rst import directives
18-
from docutils.utils import unescape
1914
from sphinx import addnodes
20-
from sphinx.domains.python import PyFunction, PyMethod, PyModule
21-
from sphinx.locale import _ as sphinx_gettext
22-
from sphinx.util.docutils import SphinxDirective
15+
from sphinx.domains.python import PyFunction, PyMethod
2316

24-
# Used in conf.py and updated here by python/release-tools/run_release.py
25-
SOURCE_URI = 'https://github.com/python/cpython/tree/3.15/%s'
2617

2718
class PyAwaitableMixin(object):
2819
def handle_signature(self, sig, signode):

0 commit comments

Comments
 (0)