Make multiline docstrings start with a newline. by anntzer · Pull Request #17125 · matplotlib/matplotlib · GitHub
Skip to content

Make multiline docstrings start with a newline. - #17125

Merged
QuLogic merged 1 commit into
matplotlib:masterfrom
anntzer:multidoc
Apr 14, 2020
Merged

QuLogic merged 1 commit into
matplotlib:masterfrom
anntzer:multidoc

Conversation

@anntzer

@anntzer anntzer commented Apr 13, 2020

Copy link
Copy Markdown
Contributor

A few are still missing.

Also inherited a couple more docstrings.

Now we just need to figure out how to flake8-enforce that...

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswell tacaswell added this to the v3.3.0 milestone Apr 13, 2020
@timhoffm

Copy link
Copy Markdown
Member

@anntzer

anntzer commented Apr 13, 2020

Copy link
Copy Markdown
Contributor Author

Removing it doesn't enforce the check (I tried), and in any case it's not actually fully fixed yet because there's still a problem with single-line docstrings which don't fit in one line when the quotes are in the same line, but do if the quotes are not there. This was raised at least once on the pydocstyle tracker (should be easy to find) and last time I check their response was basically "don't write single-line docstrings of just the line that's annoying"...

@timhoffm timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments: While we're at it, for the touched docstrings at least, finish them with a period.

Comment thread lib/matplotlib/backends/backend_pdf.py Outdated
Comment thread lib/matplotlib/backends/backend_qt5.py Outdated
Comment thread lib/matplotlib/patches.py Outdated
Comment thread lib/mpl_toolkits/axes_grid1/axes_rgb.py Outdated
Comment thread lib/mpl_toolkits/mplot3d/axes3d.py Outdated
@anntzer

anntzer commented Apr 13, 2020

Copy link
Copy Markdown
Contributor Author

sure, done

@timhoffm

timhoffm commented Apr 13, 2020

Copy link
Copy Markdown
Member

there's still a problem with single-line docstrings which don't fit in one line when the quotes are in the same line, but do if the quotes are not there.

That's a separate error code: D200. I think D213 still allows

def foo():
    """
    Single line.
    """

This was raised at least once on the pydocstyle tracker (should be easy to find) and last time I check their response was basically "don't write single-line docstrings of just the line that's annoying"...

There was PyCQA/pydocstyle#184 with D205 and D400 errors if you have very long first sentences that need to be wrapped. - IMHO they would be relatively easy to fix, but the issue was closed.

Additionally, I opened PyCQA/pydocstyle#453, because D200 cannot be fulfilled for docstrings with max. line length - 6 < text length + indent <= max. line length. This is a bit harder to fix, because pycodestyle would need to know about my line limit to allow for an exception.

For now, this means that we cannot check D200, 205, D400, because I don't think we want to or even reasonably can rewrite the first sentence to be descrpitive and fit in 69 chars (or 65 for methods) in all cases.

A few are still missing.

Also inherited a couple more docstrings.
@anntzer

anntzer commented Apr 13, 2020

Copy link
Copy Markdown
Contributor Author

ok, removed D213 from .flake8, we'll see how this goes...

@timhoffm

Copy link
Copy Markdown
Member

Just checked PEP-257 again on multi-line docstrings:

The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line.

So, if one plays strictly by the rules, it's viable to close PyCQA/pydocstyle#184 and require the authors to instead shorten the docstring. :sad: Though I don't think that's a reasonable way.

@anntzer

anntzer commented Apr 13, 2020

Copy link
Copy Markdown
Contributor Author

@QuLogic
QuLogic merged commit 717d1fa into matplotlib:master Apr 14, 2020
@anntzer
anntzer deleted the multidoc branch April 14, 2020 07:22
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Mar 10, 2024
timhoffm added a commit to timhoffm/matplotlib that referenced this pull request Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants