docs: Add collapsible overload dropdown to function signatures#597
Open
PierreQuinton wants to merge 1 commit intomainfrom
Open
docs: Add collapsible overload dropdown to function signatures#597PierreQuinton wants to merge 1 commit intomainfrom
PierreQuinton wants to merge 1 commit intomainfrom
Conversation
Adds a custom Sphinx extension (overload_dropdown.py) that uses typing.get_overloads() to detect @overload stubs and prepends a syntax-highlighted code block to the docstring of any overloaded function. A small JS/CSS pair injects an "Overloads ▶" toggle button directly into the function-signature <dt>, stacked above the existing [source] link, so readers can expand the overloads without leaving the page. Functions without overloads are completely unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
I think you tagged a guy named "overload" 😂 |
Contributor
|
Nice result! I think it's a bit brittle because we won't have time to maintain this, but let's keep it until it breaks at least. It could even become a library one day. It would be nice to talk about this to the sphinx community, to see if there would be some interest for it. I didn't read the code but I don't think it's necessary. If it works, it works. If it breaks and it's easy to fix, we (i.e. claude) fix. If one day it breaks and it's hard to fix we can always revert this PR. You can merge whenever it's ready. |
Contributor
|
Btw after merging we should check that the built docs appear correctly on mobile phone too. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a custom Sphinx extension (overload_dropdown.py) that uses typing.get_overloads() to detect @overload stubs and prepends a syntax-highlighted code block to the docstring of any overloaded function:
