bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21254: 24.5; python.el: Docstring fill-paragraph not working with st


From: Daniel Martín
Subject: bug#21254: 24.5; python.el: Docstring fill-paragraph not working with style pep-257-nn
Date: Mon, 27 Feb 2023 11:58:48 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (darwin)

Holger Schmidt <Holger.Schmidt@zmdi.com> writes:

> I write a docstring of a class method in a buffer with Python mode.
> python-fill-docstring-style is set to 'pep-257-nn.  The
> cursor is at the end of the docstring after the three quotes.
> fill-paragraph does nothing, but it should format the docstring.
>
> I move the cursor inside the docstring.  fill-paragraph formats the
> docstring with four errors: There is no newline after the first
> sentence, the first line is longer (72) than fill-column (70), the
> second line and following lines are not indented (but start at column 0),
> there is no newline at the end.  A second fill-paragraph adds the
> missing newline at the end.
>

I tested this in Emacs 29 and I get the following filled docstring:

class MyClass(object):
    def __init__(self):
        """Class initialization.  According to PEP 257 there should be
        a newline after the first sentence.  Following sentences are
        indented by 8 spaces in this case.  With
        python-fill-docstring-style set to 'pep-257-nn there should be
        a newline at the end."""
        pass

It seems like it still misses the newline after the first sentence and
the newline at the end.  Looking at the code, the missing newline after
the first sentence happens because there is no code to do that.  The
missing newline at the end is a consequence of handling the docstring as
a single-line docstring.  I think it will be fixed if we add the newline
after the first sentence.

I'm not familiar with Python or the PEP, but does anyone see any issues
if we add a new line after the first sentence of a docstring, if there
are more than one?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]