Skip to content

google+numpydoc: list methods one item each - #193

Merged
rr- merged 7 commits into
mainfrom
rework/58-methods
Nov 7, 2026
Merged

rr- merged 7 commits into
mainfrom
rework/58-methods

Conversation

@rr-

@rr- rr- commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Item 10 of BEHAVIOR.md: a Methods section gives one item per method, in Google and Numpydoc, instead of one text item holding the whole section.

  • Each method is a new DocstringMethod of the new Kind.METHOD, with the signature as written as its name, such as run(x, y=1), and its description. Docstring.methods lists them. Kind.METHOD is 13, after TEXT, so the other kinds keep their values.
  • Google takes everything before the item's colon as the signature, so annotations inside brackets such as stop(a: int) stay in it. A head with no colon is a signature alone, as napoleon reads it.
  • Numpydoc takes the whole line at column 0, as napoleon does, so it never splits a type off.
  • A section that lists no method stays a titled text item, as before, so stdlib docstrings such as datetime.time's still parse in Google.
  • Both styles compose Methods sections that read back, after Attributes. ReST and Epydoc have no methods, so they write each one as a :methods: / @methods: text field holding its signature and description. Writing the signature in the field's head would split it at its colon in ReST and fail to parse in Epydoc.
  • Based on docstring_parser: part lead text from the summary #194, which fixes the compose bug that a Methods section exposed for generated input 182, so this adds no round-trip exclusion.
  • Marked Breaking: in the CHANGELOG: code that read a Methods section as one text item keyed methods gets a DocstringMethod per method instead.
  • just update-cases changed four cases, all Methods sections that are now items: google/napoleon_sections_02, numpydoc/napoleon_sections_01 and two scipy corpus cases.
  • Parity against origin/main differs only in Google, Numpydoc and auto output, and only for inputs with a Methods section.
  • Bench against origin/main: max 1.01 on 3.14 and 1.02 on 3.8.

A Methods section was one text item holding the whole section. Read it
as napoleon does, one item per method: a DocstringMethod of the new
Kind.METHOD, named by the method's signature as written, as in
run(x, y=1), with its description. Docstring.methods lists them.

Google takes everything before the item's colon as the signature, so
annotations inside the brackets stay in it, and a head with no colon is
a signature alone. Numpydoc takes the whole line. A section that lists
no method stays a titled text item, as before.

Both styles compose Methods sections that read back. ReST and Epydoc
have no methods, so they write each as a :methods: text field holding
its signature and description.
@rr- rr- self-assigned this Nov 7, 2026
Numpydoc moves indented text before a section's first item to the long
description. Right after a summary with no blank line, it kept
blank_after_short_description False, so the text composed straight
under the summary and read back as part of it, in every section with
items, such as Parameters, Attributes and Raises.

Mark such text as a paragraph of its own whenever it is written right
after the summary, that is, unless a leading deprecation goes between
them, which keeps the summary's spacing as before.
rr- added 2 commits November 7, 2026 11:56
Generated input 182 reads back in Numpydoc now that text before a
section's first item stays apart from the summary, so it needs no
exclusion. Mark the Methods change as breaking: code that read a
Methods section as one text item gets an item per method instead.
@rr-
rr- changed the base branch from main to rework/59-lead-text November 7, 2026 10:57
rr- added 2 commits November 7, 2026 12:38
append_loose imported leading_deprecation inside the function, as
_directives imports _compose, which imports _text. The function needs
only the common classes, so move it down to _text, where every module
that uses it can import it at the top level.
Base automatically changed from rework/59-lead-text to main November 7, 2026 11:46
@rr-
rr- merged commit 797a66a into main Nov 7, 2026
26 checks passed
@rr-
rr- deleted the rework/58-methods branch November 7, 2026 11:49
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