feat: Add an RST-style docstring parser #1
Merged
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.
@plannigan, since you originally added the parser in pytkdocs, maybe you'd like to review this refactored version. Also let me know what you think is the most appropriate way to give you credits 🙂 It can be as a co-author of this PR / these commits, as a comment in the module, in the module docstring, or in the repository credits, or all of these! I'll anyway add every contributor of pytkdocs to the repository credits.
A quick explanation of the changes: there's no base parser anymore, so I exploded the class into several functions. They pass the
parsed_values
around to modify it by side-effect (not sure this is the right approach now that we're not using a class). The lines can be obtained from the docstring object, which has access to the whole object tree through its parent attribute. This removes the need for the obscure "context" dictionary we had in pytkdocs.As for what is this project: it's a revisited pytkdocs, which parses the code instead of executing it (loading it in memory to introspect objects). It's far more robust and performant, and will allow extensions to customize the behavior.