docformatter icon indicating copy to clipboard operation
docformatter copied to clipboard

docformatter removes blank line after last section in docstrings

Open Andrew-Sheridan opened this issue 5 years ago • 2 comments

Issue Summary

If a docstring has a summary and a description that consists of at least one section, then there should be a blank line between the last line of the section and the the final """ of the docstring.

Example

Given the class SomeClass below, docformatter will remove the blank line at the end of the class dosctring, after the "Methods" section. In contrast, pydocstyle will throw a D413 error if that blank line is removed: D413: Missing blank line after last section ('Methods').

Is it possible to setup docformatter to respect D413?

class SomeClass:
    """Summary.

    Methods:
        method_1
        method_2
        method_3

    """

    def __init__(self):
        """Summary.

        Details about this thing that does nothing.
        """
        pass

Andrew-Sheridan avatar Nov 24 '19 16:11 Andrew-Sheridan

The blank line after the last section is a numpy (and Google?) docstring convention. pydocstyle should only raise the D413 if it is passed the --convention=numpy or --convention=google argument. At the moment, no, docformatter can't be configured to respect the numpy or google convention. However, see #60.

weibullguy avatar Jul 25 '22 18:07 weibullguy

@weibullguy I think this issue can be closed. Using the --blank = false option from the Current Implementation in version 1.7.1 does currently remove the empty blank line from the end of the docstring. Conversly using --blank = true adds the blank line.

electric-coder avatar Jun 01 '23 04:06 electric-coder