-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
Export generator and docs api in the pest_generator trait #961
Conversation
Signed-off-by: marcfir <72923599+marcfir@users.noreply.github.com>
Important Auto Review SkippedAuto reviews are limited to the following labels: pr. Please add one of these labels to enable auto reviews. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit's AI:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Yeah, I think these types are internal and were not meant to be exported in public API. Maybe we can add a feature flag, e.g. "export-internal", to expose them?
generator/src/lib.rs
Outdated
pub mod docs; | ||
pub mod generator; |
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 can be feature-guarded
generator/src/lib.rs
Outdated
struct ParsedDerive { | ||
pub(crate) name: Ident, | ||
pub(crate) generics: Generics, | ||
pub(crate) non_exhaustive: bool, | ||
/// Parsed information of the derive and the attributes. | ||
pub struct ParsedDerive { | ||
/// The identifier of the deriving struct, union, or enum. | ||
pub name: Ident, | ||
/// The generics of the deriving struct, union, or enum. | ||
pub generics: Generics, | ||
/// Indicates whether the 'non_exhaustive' attribute is added to the 'Rule' enum. | ||
pub non_exhaustive: bool, | ||
} |
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.
and this can be feature guarded -- perhaps it can be moved to some child module and here, the feature-guard would be pub use
vs pub(crate) use
?
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.
From my point of view, a child module is a good approach. I will add a commit with the feature guard and module.
* Make internal API public with the `export-internal` feature. * Move the parse_derive functions and types to a new `parse_derive module. Signed-off-by: marcfir <72923599+marcfir@users.noreply.github.com>
Thanks for the quick review! I have added your comments. Do you have any other suggestions? |
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
} | ||
_ => panic!("grammar attribute must be a string"), | ||
}, | ||
_ => panic!("grammar attribute must be of the form `grammar = \"...\"`"), |
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.
nit: this line isn't covered by tests, but it was like that before
What it does
This PR exposes the docs module and the generator module of the pest_generator trait.
I added the missing docs for the newly exported functions, structs and modules.
Background
We are currently working on a language workbench in rust based on pest. So far we have used a separate derive macro by. But it turns out that it is easier if we do our own preprocessing of the derive attributes and just generate the parser in our own derive macro with the
pest_generaotr::generator::generate
function.Improvements
We can add a feature flag as this API was not intended to be semver sensitive.