Skip to content

Commit 2019362

Browse files
[3.13] Doc: Upgrade Sphinx to 8.1 (GH-125276) (#125278)
Doc: Upgrade Sphinx to 8.1 (GH-125276) (cherry picked from commit dd0ee20) Co-authored-by: Adam Turner <[email protected]>
1 parent 319305c commit 2019362

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

Doc/conf.py

+24-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import sys
1212
import time
1313

14+
import sphinx
15+
1416
sys.path.append(os.path.abspath('tools/extensions'))
1517
sys.path.append(os.path.abspath('includes'))
1618

@@ -62,7 +64,10 @@
6264

6365
# General substitutions.
6466
project = 'Python'
65-
copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"
67+
if sphinx.version_info[:2] >= (8, 1):
68+
copyright = "2001-%Y, Python Software Foundation"
69+
else:
70+
copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"
6671

6772
# We look for the Include/patchlevel.h file in the current Python source tree
6873
# and replace the values accordingly.
@@ -361,10 +366,14 @@
361366
}
362367

363368
# This 'Last updated on:' timestamp is inserted at the bottom of every page.
364-
html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
365-
html_last_updated_fmt = time.strftime(
366-
'%b %d, %Y (%H:%M UTC)', time.gmtime(html_time)
367-
)
369+
html_last_updated_fmt = '%b %d, %Y (%H:%M UTC)'
370+
if sphinx.version_info[:2] >= (8, 1):
371+
html_last_updated_use_utc = True
372+
else:
373+
html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
374+
html_last_updated_fmt = time.strftime(
375+
html_last_updated_fmt, time.gmtime(html_time)
376+
)
368377

369378
# Path to find HTML templates.
370379
templates_path = ['tools/templates']
@@ -596,13 +605,21 @@
596605
# mapping unique short aliases to a base URL and a prefix.
597606
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
598607
extlinks = {
599-
"cve": ("https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s", "CVE-%s"),
600-
"cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"),
601608
"pypi": ("https://pypi.org/project/%s/", "%s"),
602609
"source": (SOURCE_URI, "%s"),
603610
}
604611
extlinks_detect_hardcoded_links = True
605612

613+
if sphinx.version_info[:2] < (8, 1):
614+
# Sphinx 8.1 has in-built CVE and CWE roles.
615+
extlinks |= {
616+
"cve": (
617+
"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s",
618+
"CVE-%s",
619+
),
620+
"cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"),
621+
}
622+
606623
# Options for c_annotations
607624
# -------------------------
608625

Doc/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Sphinx version is pinned so that new versions that introduce new warnings
77
# won't suddenly cause build failures. Updating the version is fine as long
88
# as no warnings are raised by doing so.
9-
sphinx~=8.0.0
9+
sphinx~=8.1.0
1010

1111
blurb
1212

0 commit comments

Comments
 (0)