Skip to content

Commit 2d74216

Browse files
authored
Add module name to doc source (to allow intersphinx usage) (#346)
1 parent ed81f2b commit 2d74216

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

doc/conf.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import os.path
77
import sys
8+
from sphinx.writers.html5 import HTML5Translator
9+
from docutils.nodes import Element
810

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

@@ -26,9 +28,22 @@
2628

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

31+
add_module_names = False
2932

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

3336
html_theme = 'alabaster'
34-
html_static_path = ['_static']
37+
38+
39+
class MyTranslator(HTML5Translator):
40+
"""Adds a link target to name without `typing_extensions.` prefix."""
41+
def visit_desc_signature(self, node: Element) -> None:
42+
desc_name = node.get("fullname")
43+
if desc_name:
44+
self.body.append(f'<span id="{desc_name}"></span>')
45+
super().visit_desc_signature(node)
46+
47+
48+
def setup(app):
49+
app.set_translator('html', MyTranslator)

doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.. module:: typing_extensions
12

23
Welcome to typing_extensions's documentation!
34
=============================================

0 commit comments

Comments
 (0)