Skip to content
Merged
1 change: 1 addition & 0 deletions doc/.gitignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
_build/
20 changes: 20 additions & 0 deletions doc/Makefile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Empty file addeddoc/_extensions/__init__.py
Empty file.
29 changes: 29 additions & 0 deletions doc/_extensions/gh_link.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
from docutils import nodes


def setup(app):
app.add_role(
"pr", autolink("https://github.com/python/typing_extensions/pull/{}", "PR #")
)
app.add_role(
"pr-cpy", autolink("https://github.com/python/cpython/pull/{}", "CPython PR #")
)
app.add_role(
"issue",
autolink("https://github.com/python/typing_extensions/issues/{}", "issue #"),
)
app.add_role(
"issue-cpy",
autolink("https://github.com/python/cpython/issues/{}", "CPython issue #"),
)


def autolink(pattern: str, prefix: str):
def role(name, rawtext, text: str, lineno, inliner, options=None, content=None):
if options is None:
options = {}
url = pattern.format(text)
node = nodes.reference(rawtext, f"{prefix}{text}", refuri=url, **options)
return [node], []

return role
34 changes: 34 additions & 0 deletions doc/conf.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os.path
import sys

sys.path.insert(0, os.path.abspath('.'))

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'typing_extensions'
copyright = '2023, Guido van Rossum and others'
author = 'Guido van Rossum and others'
release = '4.6.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['sphinx.ext.intersphinx', '_extensions.gh_link']

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

intersphinx_mapping = {'py': ('https://docs.python.org/3.12', None)}


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']
Loading