-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Display docstrings correctly #72
Comments
Sphinx did not pick up overloading correctly when using |
For special cases we could have one definition for Sphinx and another for typing, perhaps using |
Sphinx seems to ignore such conditionals. For example, if you do: if True:
class complex:
# overload init 3 times
else:
class complex:
# overload init 2 times My idea was to pick one on Sphinx and the other for typing, but Sphinx just overloads it 5 times. The same goes for conditionals within the class definition. |
As these special cases probably mostly apply to |
Can we not override the signatures by putting the desired signature for documentation as the first line of the doc string? relevant docs class complex:
@overload
def __init__(self, ...):
...
@overload
def __init__(self, ...):
...
@overload
def __init__(self, ...):
...
def __init__(self, ...):
"""
__init__(self, ...) \ __init__(self, ...)
...
""" It also looks like there are some hooks for modifying the signature: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#event-autodoc-before-process-signature. |
Thanks! I did not know we could do overloading with this as well. This looks like it should work nicely. |
Apparently not in the version we are using, but it looks like it might work in 4.0, pending #70. One caveat is that it appears to show |
Another thing I don't really like (even in the current version) is the lack of parenthesis for the signature without arguments. I know this the standard for classes in now, but it does not make sense in this overloaded context. |
It's also not going to solve things like |
The generics and guidelines are now resolved. We can make specific issues to fix the typing implementation of specific functions and classes. |
@dlech wrote.
The text was updated successfully, but these errors were encountered: