-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metadata documentation #26
Conversation
Regarding Jimmy's comment about a usage notebook: I think that'd be useful, but it's still nice to have a very small example on the same page as the reference itself. I'd actually take the usage example (or an even more simplified example if that's possible) and move it to the top of the page, similar to what we do with the parser docs: https://libcst.readthedocs.io/en/latest/parser.html I think notebooks should be reserved for more complex examples. E.g. it'd be great to have a metadata provider example in a notebook. |
We can have the simple example in notebook and then include it from rst. That requires running a command to generate the rst from notebook and then we can include it. In that case, we'll have executable code and simple example. The other way to always make sure the example code is executable is to use doctest. |
796f864
to
22beca7
Compare
@@ -0,0 +1,60 @@ | |||
.. _libcst-metadata: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This metadata page is pretty complex since it mixed the implementation detail with usage.
For user of metadata, they only need to know to use extends BatchableMetadataProvider, use get_metadata/set_metadata, etc.
User will be also interested about what's available metadata providers.
Can we explain more of those detail in the tutorial document?
All the MetadataProvider (BaseMetadataProvider/VisitorMetadataProvider/BatchableMetadataProvider) say they are low-level, which one we recommend user to use?
We introduced .resolve() and .resolve_many() but didn't provide examples. It's not clear how user can use them. Can we provide some example code?
The doc of Position Metadata will be more clearer if we link to the example at top. https://www.sphinx-doc.org/en/1.5/markup/inline.html#role-ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some reorganization of the docs and added to the tutorial. I only added an example for resolve() and not one for resolve_many() as I think it should be pretty easy to extrapolate how to use resolve_many() from that point.
|
||
.. autoclass:: libcst.BaseMetadataProvider | ||
.. autoclass:: libcst.VisitorMetadataProvider | ||
.. autoclass:: libcst.BatchableMetadataProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference between VisitorMetadataProvider and BatchableMetadataProvider (the concept of batchable) is not clear from the docstring. Even though it links to BatchableCSTVisitor, we can probably say something here to make it more clear it's for performance sake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
Adds documentation to the metadata interface for LibCST and cleans up some internal code.
Test Plan
Ran tox and pyre.