unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Holger Schmidt <Holger.Schmidt@zmdi.com>
Cc: 21254@debbugs.gnu.org
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	[thread overview]
Message-ID: <m17cw38jdj.fsf@yahoo.es> (raw)
In-Reply-To: <jgyoaibz9qj.fsf@l53.i-did-not-set--mail-host-address--so-tickle-me> (Holger Schmidt's message of "Thu, 13 Aug 2015 13:52:20 +0200")

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?





      parent reply	other threads:[~2023-02-27 10:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 11:52 bug#21254: 24.5; python.el: Docstring fill-paragraph not working with style pep-257-nn Holger Schmidt
2019-09-26 12:04 ` Stefan Kangas
2023-02-27 10:58 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m17cw38jdj.fsf@yahoo.es \
    --to=bug-gnu-emacs@gnu.org \
    --cc=21254@debbugs.gnu.org \
    --cc=Holger.Schmidt@zmdi.com \
    --cc=mardani29@yahoo.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).