Repository navigation
common: let every meta say what it documents - #141
Merged
Merged
Conversation
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.
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.
This PR reworks how parsers record what a meta is.
Each meta now has a
kind(newcommon.Kind): param, keyword, attribute, returns, yields, raises, warns, etc. Before, users had to look at the class andargs[0], which every style spells differently (keyword,ivar,warns...).DocstringParamandDocstringRaisestake a sub-kind and reject one that isn't theirs.Nothing uses
kindyet; compose will in the next PR.No output change besides the new
kindline in the case files (just parity). Speed is within 1% of main.