| 1 |
# Configuration file for the Sphinx documentation builder. |
| 2 |
# |
| 3 |
# For the full list of built-in configuration values, see the documentation: |
| 4 |
# https://www.sphinx-doc.org/en/master/usage/configuration.html |
| 5 |
|
| 6 |
import os.path |
| 7 |
import sys |
| 8 |
|
| 9 |
from docutils.nodes import Element |
| 10 |
from sphinx.writers.html5 import HTML5Translator |
| 11 |
|
| 12 |
sys.path.insert(0, os.path.abspath('.')) |
| 13 |
|
| 14 |
# -- Project information ----------------------------------------------------- |
| 15 |
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information |
| 16 |
|
| 17 |
project = 'typing_extensions' |
| 18 |
copyright = '2023, Guido van Rossum and others' |
| 19 |
author = 'Guido van Rossum and others' |
| 20 |
release = '4.6.0' |
| 21 |
|
| 22 |
# -- General configuration --------------------------------------------------- |
| 23 |
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration |
| 24 |
|
| 25 |
extensions = ['sphinx.ext.intersphinx', '_extensions.gh_link'] |
| 26 |
|
| 27 |
templates_path = ['_templates'] |
| 28 |
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] |
| 29 |
|
| 30 |
# Use Python 3.15 for new features and Python 3.14 as a fallback for APIs that |
| 31 |
# were removed in Python 3.15. |
| •32 |
def check_object_path(key, url, path): |
| 33 |
if os.path.isfile(path): |
| 34 |
return {key: (url, path)} |
| 35 |
return {} |
| 36 |
|
| 37 |
intersphinx_mapping = {} |
| 38 |
intersphinx_mapping.update( |
| 39 |
check_object_path( |
| 40 |
'py', |
| 41 |
'https://docs.python.org/' + '.'.join([str(x) for x in sys.version_info[0:2]]) + "/", |
| 42 |
'/usr/share/doc/python' + '.'.join([str(x) for x in sys.version_info[0:2]]) + '/html/objects.inv' |
| 43 |
) |
| 44 |
) |
| 45 |
|
| 46 |
add_module_names = False |
| 47 |
|
| 48 |
# -- Options for HTML output ------------------------------------------------- |
| 49 |
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output |
| 50 |
|
| 51 |
html_theme = 'alabaster' |
| 52 |
|
| 53 |
html_theme_options = { |
| 54 |
"description": "Backported and experimental type hints for Python", |
| 55 |
# Make the sidebar "sticky" so that is stays visible when scrolling. |
| 56 |
# Also makes the sidebar appear at the top of the page on mobile. |
| 57 |
"fixed_sidebar": True, |
| 58 |
} |
| 59 |
|
| 60 |
html_sidebars = { |
| 61 |
'**': [ |
| 62 |
'about.html', |
| 63 |
'searchfield.html', |
| 64 |
'localtoc.html', |
| 65 |
] |
| 66 |
} |
| 67 |
|
| 68 |
# Don't include object entries (e.g. functions, classes) in the table of contents. |
| 69 |
toc_object_entries = False |
| 70 |
|
| 71 |
# Warn about all references where the target cannot be found. |
| 72 |
nitpicky = True |
| 73 |
|
| 74 |
|
| 75 |
class MyTranslator(HTML5Translator): |
| 76 |
"""Adds a link target to name without `typing_extensions.` prefix.""" |
| 77 |
def visit_desc_signature(self, node: Element) -> None: |
| 78 |
desc_name = node.get("fullname") |
| 79 |
if desc_name: |
| 80 |
self.body.append(f'<span id="{desc_name}"></span>') |
| 81 |
super().visit_desc_signature(node) |
| 82 |
|
| 83 |
|
| 84 |
def setup(app): |
| 85 |
app.set_translator('html', MyTranslator) |