Skip to content

Commit 91c7a2c

Browse files
[3.12] Doc: Upgrade Sphinx to 8.1 (GH-125276) (#125279)
Doc: Upgrade Sphinx to 8.1 (GH-125276) (cherry picked from commit dd0ee20) Co-authored-by: Adam Turner <[email protected]>
1 parent eb320f5 commit 91c7a2c

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

Doc/conf.py

Lines changed: 24 additions & 7 deletions
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

@@ -56,7 +58,10 @@
5658

5759
# General substitutions.
5860
project = 'Python'
59-
copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"
61+
if sphinx.version_info[:2] >= (8, 1):
62+
copyright = "2001-%Y, Python Software Foundation"
63+
else:
64+
copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"
6065

6166
# We look for the Include/patchlevel.h file in the current Python source tree
6267
# and replace the values accordingly.
@@ -339,10 +344,14 @@
339344
}
340345

341346
# This 'Last updated on:' timestamp is inserted at the bottom of every page.
342-
html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
343-
html_last_updated_fmt = time.strftime(
344-
'%b %d, %Y (%H:%M UTC)', time.gmtime(html_time)
345-
)
347+
html_last_updated_fmt = '%b %d, %Y (%H:%M UTC)'
348+
if sphinx.version_info[:2] >= (8, 1):
349+
html_last_updated_use_utc = True
350+
else:
351+
html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
352+
html_last_updated_fmt = time.strftime(
353+
html_last_updated_fmt, time.gmtime(html_time)
354+
)
346355

347356
# Path to find HTML templates.
348357
templates_path = ['tools/templates']
@@ -575,13 +584,21 @@
575584
# mapping unique short aliases to a base URL and a prefix.
576585
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
577586
extlinks = {
578-
"cve": ("https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s", "CVE-%s"),
579-
"cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"),
580587
"pypi": ("https://pypi.org/project/%s/", "%s"),
581588
"source": (SOURCE_URI, "%s"),
582589
}
583590
extlinks_detect_hardcoded_links = True
584591

592+
if sphinx.version_info[:2] < (8, 1):
593+
# Sphinx 8.1 has in-built CVE and CWE roles.
594+
extlinks |= {
595+
"cve": (
596+
"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s",
597+
"CVE-%s",
598+
),
599+
"cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"),
600+
}
601+
585602
# Options for c_annotations
586603
# -------------------------
587604

Doc/requirements.txt

Lines changed: 1 addition & 1 deletion
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)