-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(forge): add params natspec for enums #10022
base: master
Are you sure you want to change the base?
Conversation
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 (ethereum/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
@@ -46,7 +46,7 @@ impl CommentTag { | |||
} | |||
_ => { | |||
warn!(target: "forge::doc", tag=trimmed, "unknown comment tag. custom tags must be preceded by `custom:`"); | |||
return None | |||
return None; |
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, would you mind removing the inserted ;
by cargo fmt
in the PR, Foundry uses the nightly version (+nightly
)
…s#9905 Co-authored-by: gregorsternat <[email protected]>
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?
Motivation
Solution
The
forge doc
comment parser now supports parsing Enum variants in Natspecs and displaying them in a table. To declare these variants, you can use either the@param
or@custom:variant
tag.To implement this feature:
@custom:variant
tag are filtered out to prevent them from being displayed in theNote
field.variant
andparam
tags are parsed to properly display the table.Additionally:
From
trait was implemented for theComments
struct to enable the construction of the returned vector from the filtered comments.PR Checklist