|
11 | 11 | import sys
|
12 | 12 | import time
|
13 | 13 |
|
| 14 | +import sphinx |
| 15 | + |
14 | 16 | sys.path.append(os.path.abspath('tools/extensions'))
|
15 | 17 | sys.path.append(os.path.abspath('includes'))
|
16 | 18 |
|
|
62 | 64 |
|
63 | 65 | # General substitutions.
|
64 | 66 | 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" |
66 | 71 |
|
67 | 72 | # We look for the Include/patchlevel.h file in the current Python source tree
|
68 | 73 | # and replace the values accordingly.
|
|
361 | 366 | }
|
362 | 367 |
|
363 | 368 | # 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 | + ) |
368 | 377 |
|
369 | 378 | # Path to find HTML templates.
|
370 | 379 | templates_path = ['tools/templates']
|
|
596 | 605 | # mapping unique short aliases to a base URL and a prefix.
|
597 | 606 | # https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
|
598 | 607 | 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"), |
601 | 608 | "pypi": ("https://pypi.org/project/%s/", "%s"),
|
602 | 609 | "source": (SOURCE_URI, "%s"),
|
603 | 610 | }
|
604 | 611 | extlinks_detect_hardcoded_links = True
|
605 | 612 |
|
| 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 | + |
606 | 623 | # Options for c_annotations
|
607 | 624 | # -------------------------
|
608 | 625 |
|
|
0 commit comments