-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
MAINT: Add script for numpydoc linting of Public API #11121
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
base: main
Are you sure you want to change the base?
Conversation
| ROOT_PACKAGE = "xarray" | ||
|
|
||
| # full list of numpydoc error codes: https://numpydoc.readthedocs.io/en/latest/validation.html | ||
| SKIP_ERRORS = [ # TODO: Curate these for Xarray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These error code skips have mostly been inherited from my work on Parcels. These can be updated (though would be good to have input from core devs here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is doc a good place for this script?
| try: | ||
| res = validate(item) | ||
| except (AttributeError, StopIteration, ValueError) as e: | ||
| if isinstance(e, ValueError) and "Error parsing See Also entry" in str(e): # TODO: Fix later https://github.com/pydata/xarray/issues/8596#issuecomment-3832443795 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realised that there isn't any(?) linting of docstrings to make sure they adhere to the numpydoc style guide.
This PR adds a script and Pixi integration to quickly lint public docstrings. This is a similar script to that introduced in Scipy (scipy/scipy#24317 ) - though I wrote my own version which I think is a bit more robust in finding all the methods :) .
Note that numpydoc does have validation out of the box however this is on a file level, and not on the public API level (this applies to the CLI tool, pre-commit hook, and for numpydoc's integration in Sphinx - all are on the file level) - hence our need for this script.
I've used this script to find a heap of minor typos in the docs which I'll wrap into another PR.
I don't know if we can integrate this into a pre-commit hook as it requires building xarray.