Skip to content

Read the whole first paragraph as the short description - #174

Merged
rr- merged 1 commit into
mainfrom
rework/44-first-paragraph
Nov 6, 2026
Merged

rr- merged 1 commit into
mainfrom
rework/44-first-paragraph

Conversation

@rr-

@rr- rr- commented Nov 6, 2026

Copy link
Copy Markdown
Owner

The short description is now the whole first paragraph, in every style, instead of only its first line. Users with summaries wrapped over two lines get the whole sentence back, and the long description no longer starts halfway through it.

Before:

>>> d = parse("Return the :class:`Foo` for\n:meth:`bar` calls.\n\nMore.")
>>> d.short_description
'Return the :class:`Foo` for'
>>> d.long_description
':meth:`bar` calls.\n\nMore.'

After:

>>> d.short_description
'Return the :class:`Foo` for\n:meth:`bar` calls.'
>>> d.long_description
'More.'

The paragraph ends at the first blank line. It also ends at an indented line, since that starts a block, and at a section title or field, which end it already. Compose writes a multi-line short description back as it was read, so it round-trips. A line holding only whitespace before more text now counts as the blank line after the short description, so that compose writes it out and the docstring reads back the same.

This is a breaking change: code that expects short_description to be one line will now see newlines in it.

Parity against main: 11743 of 29158 docstrings differ (430 case, 1646 stdlib, 9667 generated). I checked samples from each group, and every diff comes from a summary that spans several lines. The round-trip invariant passes with no new exclusions.

Bench against main: 1.03x at most (parse epydoc). split_description scans the paragraph with one regex.

The short description is now the whole first paragraph, every line up
to the first blank line or indented line, in every style, instead of
only the first line. A summary wrapped over two lines, as in

    Return the :class:`Foo` for
    :meth:`bar` calls.

no longer leaves its second half at the start of the long description.
An indented line still ends it, as it starts a block of its own, and so
does a section title or field, as before.

A line of whitespace before more text ends the paragraph as an empty one
does, so the blank after the short description is kept for it: compose
writes it back as an empty line, and the paragraph reads back the same.
@rr- rr- self-assigned this Nov 6, 2026
@rr-
rr- merged commit 5259f8f into main Nov 6, 2026
26 checks passed
@rr-
rr- deleted the rework/44-first-paragraph branch November 6, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant