feat(forge): add params natspec for enums#10022
feat(forge): add params natspec for enums#10022DaniPopes merged 15 commits intofoundry-rs:masterfrom
Conversation
zerosnacks
left a comment
There was a problem hiding this comment.
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 <gregor.sternat@epitech.eu>
srdtrk
left a comment
There was a problem hiding this comment.
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
|
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 <gregor.sternat@epitech.eu> * refactor: add variant constructor * style: clippy issue * docs: remove formating * refactor(doc): remove the custom variant natspec for enum --------- Co-authored-by: zerosnacks <zerosnacks@protonmail.com> Co-authored-by: gregorsternat <gregor.sternat@epitech.eu>
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