From 52aac125ff2b17deb65eaae88db8698595215273 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:40:29 +0100 Subject: [PATCH 1/4] Bump to Sphinx 8.1 --- Doc/conf.py | 30 ++++++++++++++++++++++-------- Doc/requirements.txt | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Doc/conf.py b/Doc/conf.py index 287e0da46eb11c..b1bb430a0078fe 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -11,6 +11,8 @@ import sys import time +import sphinx + sys.path.append(os.path.abspath('tools/extensions')) sys.path.append(os.path.abspath('includes')) @@ -62,7 +64,10 @@ # General substitutions. project = 'Python' -copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation" +if sphinx.version_info[:2] >= (8, 1): + copyright = f"2001-%Y, Python Software Foundation" +else: + copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation" # We look for the Include/patchlevel.h file in the current Python source tree # and replace the values accordingly. @@ -94,7 +99,7 @@ # Ignore any .rst files in the includes/ directory; # they're embedded in pages but not rendered individually. # Ignore any .rst files in the venv/ directory. -exclude_patterns = ['includes/*.rst', 'venv/*', 'README.rst'] +exclude_patterns = ['includes/*.rst', 'venv/*', 'venv-3.11/*', 'README.rst'] venvdir = os.getenv('VENVDIR') if venvdir is not None: exclude_patterns.append(venvdir + '/*') @@ -361,10 +366,14 @@ } # This 'Last updated on:' timestamp is inserted at the bottom of every page. -html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) -html_last_updated_fmt = time.strftime( - '%b %d, %Y (%H:%M UTC)', time.gmtime(html_time) -) +html_last_updated_fmt = '%b %d, %Y (%H:%M UTC)' +if sphinx.version_info[:2] >= (8, 1): + html_last_updated_use_utc = True +else: + html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time())) + html_last_updated_fmt = time.strftime( + html_last_updated_fmt, time.gmtime(html_time) + ) # Path to find HTML templates. templates_path = ['tools/templates'] @@ -596,13 +605,18 @@ # mapping unique short aliases to a base URL and a prefix. # https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html extlinks = { - "cve": ("https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s", "CVE-%s"), - "cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"), "pypi": ("https://pypi.org/project/%s/", "%s"), "source": (SOURCE_URI, "%s"), } extlinks_detect_hardcoded_links = True +if sphinx.version_info[:2] < (8, 1): + # Sphinx 8.1 has in-built CVE and CWE roles. + extlinks |= { + "cve": ("https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s", "CVE-%s"), + "cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"), + } + # Options for c_annotations # ------------------------- diff --git a/Doc/requirements.txt b/Doc/requirements.txt index bf1028020b7af7..5105786ccf283c 100644 --- a/Doc/requirements.txt +++ b/Doc/requirements.txt @@ -6,7 +6,7 @@ # Sphinx version is pinned so that new versions that introduce new warnings # won't suddenly cause build failures. Updating the version is fine as long # as no warnings are raised by doing so. -sphinx~=8.0.0 +sphinx~=8.1.0 blurb From 68b9bd6231feeab65e9d012d85baa531b6d7f64f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:58:41 +0100 Subject: [PATCH 2/4] format --- Doc/conf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Doc/conf.py b/Doc/conf.py index b1bb430a0078fe..cc50836b2ece55 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -613,7 +613,10 @@ if sphinx.version_info[:2] < (8, 1): # Sphinx 8.1 has in-built CVE and CWE roles. extlinks |= { - "cve": ("https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s", "CVE-%s"), + "cve": ( + "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s", + "CVE-%s", + ), "cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"), } From 902a3856d062ec13c8587e65f4a13f9b1604c0f3 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:02:34 +0100 Subject: [PATCH 3/4] plain string --- Doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/conf.py b/Doc/conf.py index cc50836b2ece55..c9b5db4609fbd8 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -65,7 +65,7 @@ # General substitutions. project = 'Python' if sphinx.version_info[:2] >= (8, 1): - copyright = f"2001-%Y, Python Software Foundation" + copyright = "2001-%Y, Python Software Foundation" else: copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation" From d4bc22cc4c043925f85a6fd1a1ded834bfc35d5a Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:07:16 +0100 Subject: [PATCH 4/4] bang! and the dirt is gone --- Doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/conf.py b/Doc/conf.py index c9b5db4609fbd8..d7197b17865854 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -99,7 +99,7 @@ # Ignore any .rst files in the includes/ directory; # they're embedded in pages but not rendered individually. # Ignore any .rst files in the venv/ directory. -exclude_patterns = ['includes/*.rst', 'venv/*', 'venv-3.11/*', 'README.rst'] +exclude_patterns = ['includes/*.rst', 'venv/*', 'README.rst'] venvdir = os.getenv('VENVDIR') if venvdir is not None: exclude_patterns.append(venvdir + '/*')