Skip to content

common: let every meta say what it documents - #141

Merged
rr- merged 2 commits into
mainfrom
rework/3-items
Nov 6, 2026
Merged

rr- merged 2 commits into
mainfrom
rework/3-items

Conversation

@rr-

@rr- rr- commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

This PR reworks how parsers record what a meta is.

Each meta now has a kind (new common.Kind): param, keyword, attribute, returns, yields, raises, warns, etc. Before, users had to look at the class and args[0], which every style spells differently (keyword, ivar, warns...).

  • Meta classes set their own kind. DocstringParam and DocstringRaises take a sub-kind and reject one that isn't theirs.
  • Each style maps its own keys to sub-kinds.
  • Adds tests for the overridable parser methods, which had none.

Nothing uses kind yet; compose will in the next PR.

No output change besides the new kind line in the case files (just parity). Speed is within 1% of main.

@rr- rr- self-assigned this Nov 6, 2026
rr- added 2 commits November 6, 2026 10:18
Nothing tested overriding a Numpydoc section's `parse` or
`_parse_item`, a Google parser's `_build_meta` or `_setup`, or Google's
`title_colon=False`. Test each, with what the hook receives, before the
parsers' internals move under them.
What a meta documents was spread over its class and the first element
of its `args`, which each style spells its own way: a keyword param is
`key` or `keyword` in ReST, an attribute `attribute` in Google and
`ivar`, `cvar` or `var` in Epydoc, and a warning `warns` in Numpydoc.

Add `Kind` and give every meta a `kind`. Each meta class sets its own,
and a param or raises takes the sub-kind its parser read, which must
belong to the class: a `DocstringParam` cannot be given `Kind.RAISES`.
Each style maps its own keys to the sub-kinds, so no shared code needs
to know any style's spelling.

Nothing reads `kind` yet; composing by kind is the next step. Case
files show it, and `just parity` finds no other difference.
@rr- rr- changed the title docstring_parser: build every meta from an Item common: let every meta say what it documents Nov 6, 2026
@rr-
rr- merged commit 6a7d8e3 into main Nov 6, 2026
26 checks passed
@rr-
rr- deleted the rework/3-items branch November 6, 2026 13:15
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