Skip to content

Add blackdoc and docformatter to wrap docstrings to 79 chars #497

Closed

Description

@weiji14

Description of the desired feature

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

Activity

  1. added
    good first issue
    scipy-sprint
    on Jun 28, 2020
  2. seisman commented on Jul 15, 2020

    @seisman
    Member

    Just tried blackdoc. I think it can only format the codes in docstrings, but can't wrap other non-code docstrings.

  3. leouieda commented on Jul 15, 2020

    @leouieda
    Member

    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 👍

  4. weiji14 commented on Jul 15, 2020

    @weiji14
    MemberAuthor

    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.

  5. leouieda commented on Jul 15, 2020

    @leouieda
    Member

    Yes but our docstrings follow the NumPy style, not necessarily PEP257 😔 I haven’t seen those other tools, though. Might be worth investigating.

  6. weiji14 commented on Jul 15, 2020

    @weiji14
    MemberAuthor

    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).

  7. changed the title [-]Add blackdoc to wrap docstrings to 79 chars[/-] [+]Add blackdoc and docformatter to wrap docstrings to 79 chars[/+] on Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuescipy-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions