Skip to content

Commit 175b28d

Browse files
g-despotclaude
andcommitted
docs: suppress @typing.overload signature stacking
Sphinx autodoc detects @overload via AST parsing and stacks every overload variant with full inline type hints, ignoring autodoc_typehints = "description". Patch ModuleAnalyzer.analyze to clear overload collection so each method renders as a single clean signature with type info in the description block. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c307d97 commit 175b28d

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

docs/conf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ def chdir(directory):
9292
"autosectionlabel",
9393
]
9494

95+
# Suppress @typing.overload signature expansion: render only the implementation
96+
# signature, otherwise autodoc stacks every overload variant with full type hints.
97+
from sphinx.pycode import ModuleAnalyzer as _ModuleAnalyzer
98+
99+
_orig_analyze = _ModuleAnalyzer.analyze
100+
101+
102+
def _analyze_without_overloads(self):
103+
_orig_analyze(self)
104+
self.overloads = {}
105+
106+
107+
_ModuleAnalyzer.analyze = _analyze_without_overloads
108+
95109
# -- Options for HTML output -------------------------------------------------
96110

97111
# The theme to use for HTML and HTML Help pages. See the documentation for

0 commit comments

Comments
 (0)