|
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 |
|
|
56 | 58 |
|
57 | 59 | # General substitutions. |
58 | 60 | 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" |
60 | 65 |
|
61 | 66 | # We look for the Include/patchlevel.h file in the current Python source tree |
62 | 67 | # and replace the values accordingly. |
|
339 | 344 | } |
340 | 345 |
|
341 | 346 | # 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 | + ) |
346 | 355 |
|
347 | 356 | # Path to find HTML templates. |
348 | 357 | templates_path = ['tools/templates'] |
|
575 | 584 | # mapping unique short aliases to a base URL and a prefix. |
576 | 585 | # https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html |
577 | 586 | 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"), |
580 | 587 | "pypi": ("https://pypi.org/project/%s/", "%s"), |
581 | 588 | "source": (SOURCE_URI, "%s"), |
582 | 589 | } |
583 | 590 | extlinks_detect_hardcoded_links = True |
584 | 591 |
|
| 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 | + |
585 | 602 | # Options for c_annotations |
586 | 603 | # ------------------------- |
587 | 604 |
|
|
0 commit comments