Skip to content
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

Ability to disable overloaded function signatures being presented when autodoc_typehints is "signature" or "both" #10359

Open
AbstractUmbra opened this issue Apr 17, 2022 · 3 comments
Labels
extensions:autodoc type:enhancement enhance or introduce a new feature

Comments

@AbstractUmbra
Copy link

Is your feature request related to a problem? Please describe.
When the setting above is present and enabled, the build documentation presents multiple entries for ov
erloaded function signature:
Code_7hPM5g2RLm

Describe the solution you'd like
As discussed in #10305 I would like to request a setting to override within conf.py to disable this functionality only.

Describe alternatives you've considered
Due to the overloaded signatures being rather important, I am unsure if it would be possible to perhaps "collapse" these and only show one signature, but have a button/link present in the built documentation to reveal the overloaded signatures.
Otherwise perhaps it can

Additional context
N/A but can present anything if you need.

@AbstractUmbra AbstractUmbra added the type:enhancement enhance or introduce a new feature label Apr 17, 2022
@mbraakhekke
Copy link

mbraakhekke commented Aug 4, 2022

I fully support this request. I prefer to explain the different usages of overloaded functions but show only the signature of the actual function (with a "universal" signature). Listing all individual overloads can really hurt the readability, IMO.
At the risk of being greedy: it would be great if this could be controlled at the level of individual functions/methods.

Is there a workaround possible, currently? I tried to see if I could achieve this with the autodoc-skip-member event but it's emitted only once, not for each individual overload.

Minor point: the overloaded signatures are also shown if autodoc_typehints = "description".

@stinodego
Copy link

I would love to have this as an option.

The docs can become unreadable quickly if you have any mildly complex overloading going on. For example, this is the read_excel functionality of Polars:
https://pola-rs.github.io/polars/docs/python/dev/reference/api/polars.read_excel.html

@picnixz
Copy link
Member

picnixz commented Aug 28, 2023

It shouldn't be that hard to do with a configuration value. What we do is redocumenting all possible signatures so we could simply skip this step.

Controlling something at the level of the function should be done via :meta:.
The next feature I am working towards to is to implement arbitrary meta "processors". The idea is that you can hack into the directive being executed by injecting some extra content using this meta field. When using autodoc the content would be injected into the directive and you would have a fine control of the autodoc directive.

But this would require a complete refactorisation of autodoc (which IMHO should be done because it's really hard to extend existing implementations).


A note for the future me: the code responsible for detecting overloaded functions is the ModuleAnalyzer IIRC. It's one of the component that needs to be improved one day in order to also detect imports correctly and also to be able to subclass it correctly in extensions (currently its implementation is tightly coupled with autodoc and it becomes a pain for extensions that want to improvr it).

At one point I want to collect every autodoc issues because there arr many that are the same or have the same cause.

As a matter of fact, since Python 3.11 or 12, overloaded functions are known at runtime (which is not the case prior to that since the overload decorator acted as a pure identity function).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extensions:autodoc type:enhancement enhance or introduce a new feature
Projects
None yet
Development

No branches or pull requests

5 participants