Repository navigation
End Numpydoc sections at undeclared headings - #166
Merged
Merged
Conversation
After the first section, an underlined heading that no section declares, such as "See also" or "Options", was read as items of the section before it: the title, its dashes and its text became fake returns or params. Such a heading now ends the section and becomes a text meta, keyed by its title in snake case, with the title kept in the new title field so compose writes it back. Headings in an examples section stay there, since doctest output may hold a table whose header row looks underlined. Headings before the first section stay in the description, as before.
rr-
force-pushed
the
rework/27-numpydoc-headings
branch
from
November 6, 2026 17:33
3298f57 to
573f65f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After the first section, Numpydoc read an underlined heading that no section declares as items of the section before it. A lowercase
See alsoafterReturns, which numpy itself writes in places, came out as three fake returns:Before: returns
inds,See also,--------andtriu_indices. Now: the returninds, then a text meta with keysee_also, titleSee alsoand the section's text as its description.The rule:
Custom Titlegivescustom_title), and the newDocstringMeta.titlekeeps the title as written, so compose writes it back and the docstring round-trips.Examplessection stay in it, since doctest output may hold a table whose header row looks underlined, as innumpy.einsum_path.Matching titles regardless of case, and underlines shorter than the title, are separate changes.
Parity against main: 13 of 29,127 docstrings differ, and each has an undeclared heading after a section.
See alsoinnumpy.can_castandnumpy.tril_indices,Optionsinscipy.optimize._minimize_powell, andMethodsin two scipy classes.Bench on 3.8: Numpydoc parse is 1.04x of main, with and without sections, and everything else is 0.98–1.01x.