Skip to content

Commit dac4c6e

Browse files
authored
[3.14] Docs: Replace hardcoded SOURCE_URI with patchlevel check (GH-150850) (#150856)
1 parent d5ebac6 commit dac4c6e

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
# ---------------------
@@ -77,7 +75,7 @@
7775
# We look for the Include/patchlevel.h file in the current Python source tree
7876
# and replace the values accordingly.
7977
# See Doc/tools/extensions/patchlevel.py
80-
version, release = import_module('patchlevel').get_version_info()
78+
version, release = get_version_info()
8179

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

556+
558557
# Options for sphinx.ext.extlinks
559558
# -------------------------------
560559

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

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.14/%s'
2617

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

0 commit comments

Comments
 (0)