-
Notifications
You must be signed in to change notification settings - Fork 220
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
Wrap docstrings to 79 chars and check with flake8 #384
Conversation
Jupyter, IPython, and other IDEs don't usually render the rst in the docstrings and just show them literally. The problem is that many of these break lines at 79 characters. So docstrings with more characters look terrible in these settings and sometimes almost unreadable. Wrap all docstrings to 79 characters instead of Black's 88. Set `max-doc-length=79` to make flake8 check if any docstring exceeds it. The setting checks comments as well and we found no way of disabling that. So we'll format comments to 79 characters for consistency as well. Minor modifications to the first line of some docstrings was required to make them fit into a single line. Also made minor modifications on some doctests to wrap to 79 characters.
cc @GenericMappingTools/python-contributors please take note of this when writing your docstrings. flake8 will complain so you can't merge things in by mistake but it's good to know why flake8 is complaining :-) |
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.
Just one minor suggestion (update a url link), otherwise looks good to merge.
CONTRIBUTING.md
Outdated
#### Docstrings | ||
|
||
**All docstrings** should follow the | ||
[numpy style guide](https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt). |
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.
The link has moved to https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard
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.
👍 thanks for catching that!
Merged. Please note that this will impact all current PRs since they are likely to have conflicts with master now. |
Jupyter, IPython, and other IDEs don't usually render the rst in the
docstrings and just show them literally. The problem is that many of
these break lines at 79 characters. So docstrings with more characters
look terrible in these settings and sometimes almost unreadable. Wrap
all docstrings to 79 characters instead of Black's 88. Set
max-doc-length=79
to make flake8 check if any docstring exceeds it.The setting checks comments as well and we found no way of disabling
that. So we'll format comments to 79 characters for consistency as well.
Minor modifications to the first line of some docstrings was required to
make them fit into a single line. Also made minor modifications on some
doctests to wrap to 79 characters.
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.