-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(forge): add params natspec for enums #10022
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
Conversation
zerosnacks
left a comment
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.
Hi @samooyo, thanks for your PR!
Given that Solidity has not prioritised adding support for this in the current release I think it is reasonable to add this ahead of time and make adjustments where needed afterwards.
Would you mind adding a test case for this?
The proposed syntax of Solidity (argotorg/solidity#14193) is as follows:
enum Color {
Red,
/// @notice example of notice
/// @dev example of dev
Green,
/// @dev example of dev
Blue
}
Once Solidity has implement support for this in-line syntax we can expand it to also cover this case.
Personally I think the @param syntax as proposed makes most sense here
…s#9905 Co-authored-by: gregorsternat <[email protected]>
srdtrk
left a comment
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.
Since it seems like CommentTag::Custom("variant".to_string()) is commonly used in this PR. Would it be ok to add the following method to CommentTag in parser.
/// Create a new instance of [CommentTag::Custom] with the `variant` tag.
pub fn variant() -> Self {
Self::Custom("variant".to_string())
}On a side note @zerosnacks, I'm using the parser crate in an external project for a natspec linter I'm building (it's private at the moment) in my free time. I also have to maintain a copy of the parser module since it is not published on crates.io. Would you be open to refactor and publish the parser as a crate if I create an issue for this?
Hi @zerosnacks, thanks for the feedback! From what I can see, there currently aren’t any existing tests for the |
|
0.8.30 adds NatSpec support for enum value definitions: #10455 |
da74ec7 to
7f359b4
Compare
onbjerg
left a comment
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.
Hi @samooyo, could you take a look at updating this implementation for the new feature as released in solc 0.8.30?:)
|
Hi @samooyo, let me know if you are blocked on supporting variant docs from argotorg/solidity#15956 |
Hi @onbjerg, from my understanding, Solang has not yet implemented this new Solidity feature. So I’ve just removed the |
|
no this is ok, ty |
* feat(forge): add params natspec for enums * chore: cargo fmt * fix: clippy errors * add @gregorsternat as co-author given their earlier work on foundry-rs#9905 Co-authored-by: gregorsternat <[email protected]> * refactor: add variant constructor * style: clippy issue * docs: remove formating * refactor(doc): remove the custom variant natspec for enum --------- Co-authored-by: zerosnacks <[email protected]> Co-authored-by: gregorsternat <[email protected]>
Motivation
Solution
The
forge doccomment parser now supports parsing Enum variants in Natspecs and displaying them in a table. To declare these variants, you can use either the@paramor@custom:varianttag.To implement this feature:
@custom:varianttag are filtered out to prevent them from being displayed in theNotefield.variantandparamtags are parsed to properly display the table.Additionally:
Fromtrait was implemented for theCommentsstruct to enable the construction of the returned vector from the filtered comments.PR Checklist