Skip to content

Commit 3f1d197

Browse files
committed
Replace hardcoded SOURCE_URI with patchlevel check
1 parent 41eb8ee commit 3f1d197

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

Doc/conf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
sys.path.append(os.path.abspath('tools/extensions'))
1616
sys.path.append(os.path.abspath('includes'))
1717

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

2120
# General configuration
2221
# ---------------------
@@ -555,16 +554,20 @@
555554
r'https://unix.org/version2/whatsnew/lp64_wp.html',
556555
]
557556

557+
558558
# Options for sphinx.ext.extlinks
559559
# -------------------------------
560560

561+
v = get_header_version_info()
562+
branch = "main" if v.releaselevel == "alpha" else f"{v.major}.{v.minor}"
563+
561564
# This config is a dictionary of external sites,
562565
# mapping unique short aliases to a base URL and a prefix.
563566
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
564567
extlinks = {
565568
"oss-fuzz": ("https://issues.oss-fuzz.com/issues/%s", "#%s"),
566569
"pypi": ("https://pypi.org/project/%s/", "%s"),
567-
"source": (SOURCE_URI, "%s"),
570+
"source": (f"https://github.com/python/cpython/tree/{branch}/%s", "%s"),
568571
}
569572
extlinks_detect_hardcoded_links = True
570573

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

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

0 commit comments

Comments
 (0)