Skip to content

Comments

docs: Add collapsible overload dropdown to function signatures#597

Open
PierreQuinton wants to merge 1 commit intomainfrom
docs-dropdown-overloads
Open

docs: Add collapsible overload dropdown to function signatures#597
PierreQuinton wants to merge 1 commit intomainfrom
docs-dropdown-overloads

Conversation

@PierreQuinton
Copy link
Contributor

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:
image

image

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>
@PierreQuinton PierreQuinton added the cc: docs Conventional commit type for changes to the documentation. label Feb 24, 2026
@ValerianRey
Copy link
Contributor

I think you tagged a guy named "overload" 😂

@ValerianRey
Copy link
Contributor

ValerianRey commented Feb 24, 2026

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.

@ValerianRey
Copy link
Contributor

Btw after merging we should check that the built docs appear correctly on mobile phone too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: docs Conventional commit type for changes to the documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants