Skip to content

Add module name to doc source (to allow intersphinx usage) #346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import os.path
import sys
from sphinx.writers.html5 import HTML5Translator
from docutils.nodes import Element

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

Expand All @@ -26,9 +28,22 @@

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

add_module_names = False

# -- 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']


class MyTranslator(HTML5Translator):
"""Adds a link target to name without `typing_extensions.` prefix."""
def visit_desc_signature(self, node: Element) -> None:
desc_name = node.get("fullname")
if desc_name:
self.body.append(f'<span id="{desc_name}"></span>')
super().visit_desc_signature(node)


def setup(app):
app.set_translator('html', MyTranslator)
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.. module:: typing_extensions

Welcome to typing_extensions's documentation!
=============================================
Expand Down