-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Put constructor parameter docstring into __init__ docstrings #4414
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
Comments
I understand the usefulness docstrings at right places. Can I take this responsibility to place doctrings about the parameters at the right place? Before
After
|
@ashish-hacker wait. I was about to say yes and refer you to the numpydoc guide. Pinging @ColCarroll for his opinion on the question: Should we follow PEP 257 (this issue) or numpydoc (close this issue)? |
Thanks @michaelosthege for the clarification. |
Sorry for missing this! tl;dr: I'm strongly in favor of this. Given the number of people using pymc3 in jupyter notebooks with tab completion, I have a strong desire to putting parameters in The numpydoc guidance strikes me as funny to the point of maybe being a typo -- classes are sometimes intended to be constructed from other entry points than init (or in addition to init). For example, I can not create a Will numpydoc flag this? |
I personally have a slight preference for numpydoc style and documenting classes and their init method in the class docstring, but any of the two options are fine. To help make an informed decision, I have checked how html and jupyter docs are generated, and it looks like what is shown is first the class docstring followed by the init docstring (and in cases where the init docstring is empty, the init of the parent is pulled in). Here is the output for Metropolis: html jupyter
Haven't checked, but I bet that as long as there is a class docstring (even if only one line) numpydoc won't complain. |
What happens with |
It's in pandas docstring guide instead of numpydoc ones: https://pandas.pydata.org/pandas-docs/stable/development/contributing_docstring.html right below the first code block. 🤷 |
@OriolAbril in VSCode the |
|
So, Now Can I work on this (by following PEP 257)? @michaelosthege |
@ashish-hacker yes, go ahead |
@ashish-hacker and make sure to start out with a smaller PR - maybe just the samplers first. Just so we can see if it causes problems with the documentation |
Sure @michaelosthege . I will do it for a single class first or a file. Then You can review it. |
Can you guide me @michaelosthege ? Will I continue doing this for other classes in the code base? |
Description of your problem
Reviewing #4411 I noticed that many classes have the documentation about the
__init__
parameters in the class docstring and are missing the__init__
docstring entirely.According to PEP 257...
(formatting by me)
Examples:
The text was updated successfully, but these errors were encountered: