-
Notifications
You must be signed in to change notification settings - Fork 124
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
Docstring guidelines #1943
Comments
Have you thought about omitting the Returns: ... section, when it doesn't add context to/simplify the return annotation? In (#1924) I'm taking inspiration from these methods, but they seem to state the same thing 3 times: narwhals/narwhals/dataframe.py Lines 634 to 638 in 46fec73
narwhals/narwhals/dataframe.py Lines 680 to 684 in 46fec73
narwhals/narwhals/dataframe.py Lines 2014 to 2018 in 46fec73
All of the above all seem less useful than cases like below: narwhals/narwhals/translate.py Lines 111 to 112 in 46fec73
narwhals/narwhals/translate.py Lines 332 to 334 in 46fec73
narwhals/narwhals/translate.py Lines 893 to 894 in 46fec73
narwhals/narwhals/functions.py Lines 2211 to 2212 in 46fec73
|
That would be nice, but unfortunately it seems we need the Returns section for the type annotations to appear in the rendered docstrings https://narwhals-dev.github.io/narwhals/api-reference/expr/ If we had a way to get the return type annotation to appear in the signature in the rendered docstrings, then maybe it'd be ok to remove the 'returns' in the docstrings TBH it might not be a bad idea to use Sphinx / readthedocs for the API reference, and keep mkdocs for the user guide, like how Polars does |
Interesting 🤔 So are you saying mkdocs needs to have both of these, if you only need the signature? narwhals/narwhals/translate.py Lines 288 to 335 in 46fec73
I would have thought they were independent |
Should we just add these guidelines to the contributing guide? If I am new to a repo/project, I would not be searching for issues to know how to write docs 🙈 |
@MarcoGorelli not sure how this works, but... Found an example function with overloads and no returns section (via https://mkdocstrings.github.io/#used-by) |
thanks - so, if there's overloads, then the signature shows, but not if there's not (e.g. https://textual.textualize.io/api/logger/#textual.on) looks like for |
Ah that's odd. Probably worth a look through some more of the used by to see if someone else has figured it out I think that style of the signature could be an improvement for |
That's something I dislike about polars docs. You search something in the guide and you miss the API part. You have to go to the API site. IMHO not great when you are learning about it or you only use it occasionally. |
In #1942 I mentioned a desire to keep the package size down. One way to do this is by reducing overly-long docstrings.
Here are some general guidelines:
nw.from_native
and apply operationto_native
, some can use selectors ornw.all
...this is all OK. Just keep it minimalAlso, the reason many of the current docstrings are so long is because that's how I'd originally encouraged them to be. I think that was a mistake on my part, I need to acknowledge this, and as the project has evolved, it's time to revisit
The text was updated successfully, but these errors were encountered: