-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: general discussion of our docstring sharing system #19932
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
Some first thoughts:
|
A typical occurrence of a problem is a function that only lives in generic.py, and has a template with substituted values. But since it only lives in generic.py, it only gets substituted with 'NDFrame' et al. One possibility is to actually add them to Lines 3482 to 3484 in 52559f5
Other possibility is to update the docstring to just be generic (replace 'klass' with Series/DataFrame). Although then we would also need to add examples of both. Last possibility would also be to do this template filling without overriding the actual method, but only filling the docstring with eg
(or go with some fancy metaclassing to do this automatically ...) |
Another aspect to consider: to what extent do we necessarily want separate docstrings for Series/DataFrame? Anyway, some feedback on all the above thoughts is welcome :-) |
Personally, I'm fine with using the same docstring for Series / DataFrame
in some cases, as long as the signature is identical. I would need to go
through some individual examples though.
…On Fri, Mar 2, 2018 at 9:50 AM, Joris Van den Bossche < ***@***.***> wrote:
Another aspect to consider: to what extent do we necessarily want separate
docstrings for Series/DataFrame?
For certain methods it might be fine to just have a common docstring
(without substituting things), with examples that show both Series and
DataFrame?
Anyway, some feedback on all the above thoughts is welcome :-)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19932 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIizMQP60VEU11DnXLfMk8LiGYqXtks5taWosgaJpZM4SVzot>
.
|
Any opinions on this:
|
Yes, I support that. I started the shared doc guide this morning, and noticed what you meant by that. |
FYI at https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.set_axis.html there's:
|
Currently in many places we write docstrings as string values inside a
_shared_docs
dictionary, and then add this docstring to the method with a decorator like@Appender(_shared_docs['where'])
, or possibly with substitution of variables in the template docstring with@Appender(_shared_docs['where'] % _shared_doc_kwargs)
.Apart from that, we have some other custom ways to generate them, typically for a specific set of methods (eg all statistical methods like mean, sum, median, ..).
This system is important to not duplicate content too much, but also has some drawbacks:
And in general in can be hard/complicated to add good examples, as those are typically specific to one method, so you need to write them in separate strings and then add to the appropriate docstring.
So therefore opening this issue, to gather ideas on whether we can improve this workflow, without sacrificing the deduplication and flexibility of the current system?
The text was updated successfully, but these errors were encountered: