You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add blackdoc and docformatter to wrap docstrings to 79 chars #497
blackdoc is like black, but for docstrings! This will help with applying #384, and make our docstrings consistent with our code.
Would prefer for someone new-ish to take this on. Some knowledge of git commit-hooks would be useful, but you can see pydata/xarray#4177 as an example on how another library has implemented it.
Are you willing to help implement and maintain this feature? No
The problem with formatting the dosctring text is that it’s restructuredtext, not Python. So the rules are different. But even if blackdoc does only the doctests, it would be nice to have automated 👍
A quick search turns up docformatter that follows PEP 257 (didn't realize there's a docstring convention)! We might be able to mix both, but not sure how well they play nicely with one another. There's also PEP 287 which is specifically for RestructuredText, and blacken-docs that looks similar to blackdoc but only for .rst, .md files (instead of .py files). I found most of this quoted over at psf/black#144.
There's some similarities between the standards (see this stackoverflow answer for an overview), but yes, let's stick to numpydoc.
Actually after some thought, it might be better to make this an optional tool, since we already have black and pylint. Adding one more into the mix might act as a barrier to new contributors (who often face dozens of lint errors on their first Pull Request).
Activity
seisman commentedon Jul 15, 2020
Just tried blackdoc. I think it can only format the codes in docstrings, but can't wrap other non-code docstrings.
leouieda commentedon Jul 15, 2020
The problem with formatting the dosctring text is that it’s restructuredtext, not Python. So the rules are different. But even if blackdoc does only the doctests, it would be nice to have automated 👍
weiji14 commentedon Jul 15, 2020
A quick search turns up docformatter that follows PEP 257 (didn't realize there's a docstring convention)! We might be able to mix both, but not sure how well they play nicely with one another. There's also PEP 287 which is specifically for RestructuredText, and blacken-docs that looks similar to blackdoc but only for
.rst,.mdfiles (instead of.pyfiles). I found most of this quoted over at psf/black#144.leouieda commentedon Jul 15, 2020
Yes but our docstrings follow the NumPy style, not necessarily PEP257 😔 I haven’t seen those other tools, though. Might be worth investigating.
weiji14 commentedon Jul 15, 2020
There's some similarities between the standards (see this stackoverflow answer for an overview), but yes, let's stick to numpydoc.
Actually after some thought, it might be better to make this an optional tool, since we already have
blackandpylint. Adding one more into the mix might act as a barrier to new contributors (who often face dozens of lint errors on their first Pull Request).[-]Add blackdoc to wrap docstrings to 79 chars[/-][+]Add blackdoc and docformatter to wrap docstrings to 79 chars[/+]