-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Autodoc feature request: Attribute docstring signatures #9025
Comments
Possibly related: I have a Pybind project with a class with a property with the following docstring:
When I create some documentation without autodoc, I see that a newline matters. To generate what I see in your example:
I'm wondering if autodoc adds this newline as well, and if I can remove it somehow. |
If sphinx supports pyi files, it would be better than using docstrings to specify types. |
Im not thrilled with the idea of using pyi files if only because it means juggling even more files for an extension module |
I agree with @shimizukawa's idea. The .pyi file is now the standard of Python to distribute type information (see PEP 561; https://www.python.org/dev/peps/pep-0561/). It also helps type checkers, IDEs, and other typing tools. There is no reason to add an original docstring format only for documentation to me. |
Is there any further documentation on pyi files? I have no idea where to put them or how to write them |
never mind, i think I figured it out. I agree that this is the best way to go |
Thank you for your understanding. |
Is your feature request related to a problem? Please describe.
Right now theres no way for a docstring for an attribute to define its type option, only a type field, which is frustrating when documenting extension modules. I propose the
autodoc_docstring_signature
feature be extended to include attributes to allow type documentation from within non-python code.Currently the only workarounds I'm aware of are
.. autoproperty:: field(type)
) which is kinda weird:type:
field which makes the documentation a lot messier looking than I would likeDescribe the solution you'd like
similar to functions, allow for the first line of an attribute docstring to contain a signature in the form
name: type
, and have that type automatically added to the:type:
option (not field) of the auto documented member.Describe alternatives you've considered
:type:
fields on the first line of a docstring to make them into options insteadname(self)-> type
) (this is probably the easiest to implement by reusing the method signature function)Additional context
I'm open to doing a PR for this feature, I just want feedback on what the best way to go about doing it is, and if anyone else wants it.
The text was updated successfully, but these errors were encountered: