pest-parser / pest

The Elegant Parser
https://pest.rs
Apache License 2.0
4.67k stars 261 forks source link

Add allow(missing_docs) on Rule struct #923

Closed pgimalac closed 1 year ago

pgimalac commented 1 year ago

This PR adds #[allow(missing_docs)] to the Rule struct in order to fix https://github.com/pest-parser/pest/issues/326.

The only element which was missing documentation for me was the EOI variant, tell me if you would rather add some hardcoded documentation to that variant.

tomtau commented 1 year ago

If we add a comment on EOI, does it work? Maybe that would be preferable? The comment could just say "end-of-input"?

tomtau commented 1 year ago

@pgimalac

tomtau commented 1 year ago

@pgimalac would this work: https://github.com/pest-parser/pest/pull/926/files#diff-b40e16517d351a155bd4ca1e43b33643158df95855f86a37f3b87f5a90afba30R237 ?

pgimalac commented 1 year ago

@tomtau yes it works, that's what I did initially (before seeing the comment from @CAD97 on the issue I linked saying to just add an allow(missing_docs))

One thing I'm not sure is whether other builtin rules could appear, for example I have the WHITESPACE rule in my project, but as I redefined it in my grammar I was able to add a comment. This is the main reason why I think #[allow(missing_docs)] might be a safer fix.

tomtau commented 1 year ago

I think they don't, but if they do, we can see if we can add rustdocs to them? One way to verify is you can use my pest fork as a git dependency, remove that whitespace rule and see if there are any warnings about missing comments?

tomtau commented 1 year ago

added the comment to EOL: https://github.com/pest-parser/pest/pull/926 -- if it doesn't work, feel free to reopen this PR to add #[allow(missing_docs)]

attila-lin commented 1 year ago

upgrade to "2.7.4", still get warning

error: missing documentation for a variant
 --> rua\src\analyze\annotation\single_annotation_parser.rs:7:10
  |
7 | #[derive(Parser)]
  |          ^^^^^^
  |
note: the lint level is defined here
 --> rua\src\lib.rs:5:9
  |
5 | #![deny(missing_docs)]
  |         ^^^^^^^^^^^^
  = note: this error originates in the derive macro `Parser` (in Nightly builds, run with -Z macro-backtrace for more info)
tomtau commented 1 year ago

@attila-lin and your own grammar is all documented?

attila-lin commented 1 year ago

Yes, I think so. Wonder if anyone have the same situation?

tomtau commented 1 year ago

@attila-lin i guess your code is not public, is it? I'm trying to look for some code to reproduce it -- the one posted originally by @librelois doesn't seem to be accessible now: https://git.duniter.org/nodes/rust/duniter-rs/blob/migrate_to_pest/documents/v10/mod.rs#L40

attila-lin commented 1 year ago

Yes, not public.

I make it pub(crate) solve this problem. Thank you for your response. @tomtau :blush: