-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Allow NatSpec comments for state variables #8532
Allow NatSpec comments for state variables #8532
Conversation
9e6d5c4
to
84f27c4
Compare
Please squash. |
0302dd8
to
7c0ee1a
Compare
@chriseth i'm not sure whether it is good to forbid
contract ReputationMiningCycle is ReputationMiningCycleStorage, PatriciaTreeProofs, DSMath {
/// @notice Minimum reputation mining stake in CLNY
uint256 constant MIN_STAKE = 2000 * WAD;
/// @notice Size of mining window in seconds
uint256 constant MINING_WINDOW_SIZE = 60 * 60 * 24; // 24 hours
...
}
contract ERC20Migrator {
using SafeERC20 for IERC20;
/// Address of the old token contract
IERC20 private _legacyToken;
/// Address of the new token contract
ERC20Mintable private _newToken;
...
}
contract Fund {
/// Mapping of ether shares of the contract.
mapping(address => uint) shares;
/// Withdraw your share.
function withdraw() public {
(bool success,) = msg.sender.call{value: shares[msg.sender]}("");
if (success)
shares[msg.sender] = 0;
}
} |
8d0f2ec
to
7fa485e
Compare
@aarlt |
fb7f327
to
c248c78
Compare
Needs rebase. |
cab1760
to
ce68386
Compare
Needs rebase again. |
ce68386
to
0a38ec8
Compare
Needs rebase. |
docs/natspec-format.rst
Outdated
@@ -82,10 +85,10 @@ Tag | |||
=========== =============================================================================== ============================= | |||
``@title`` A title that should describe the contract/interface contract, interface | |||
``@author`` The name of the author contract, interface, function | |||
``@notice`` Explain to an end user what this does contract, interface, function | |||
``@dev`` Explain to a developer any extra details contract, interface, function | |||
``@notice`` Explain to an end user what this does contract, interface, function, state variable |
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.
``@notice`` Explain to an end user what this does contract, interface, function, state variable | |
``@notice`` Explain to an end user what this does contract, interface, function, public state variable |
docs/natspec-format.rst
Outdated
``@param`` Documents a parameter just like in doxygen (must be followed by parameter name) function | ||
``@return`` Documents the return variables of a contract's function function | ||
``@return`` Documents the return variables of a contract's function function, state variable |
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.
``@return`` Documents the return variables of a contract's function function, state variable | |
``@return`` Documents the return variables of a contract's function function, public state variable |
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.
Thats true, @return
should only be allowed on public state-variables.
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.
I added now a check: @return
is now only allowed on public state-variables. I added also a test for this.
if (returnTagsVisited > 1) | ||
appendError( | ||
_node.documentation()->location(), | ||
"Documentation tag \"@" + docTag.first + "\" is only allowed once on state-variables."); |
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.
"Documentation tag \"@" + docTag.first + "\" is only allowed once on state-variables."); | |
"Documentation tag \"@" + docTag.first + "\" is only allowed once on state-variables." | |
); |
{ | ||
parseDocStrings(_variable, _variable.annotation(), validPublicTags, "non-public state variables"); | ||
if (_variable.annotation().docTags.count("notice") > 0) | ||
m_errorReporter.warning(9098_error, _variable.documentation()->location(), "Documentation tag on non-public state variables will be disallowed in 0.7.0. You will need to use the @dev tag explicitly."); |
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.
Please wrap this line.
m_errorReporter.warning(9098_error, _variable.documentation()->location(), "Documentation tag on non-public state variables will be disallowed in 0.7.0. You will need to use the @dev tag explicitly."); | ||
} | ||
if (_variable.annotation().docTags.count("title") > 0 || _variable.annotation().docTags.count("author") > 0) | ||
m_errorReporter.warning(4822_error, _variable.documentation()->location(), "Documentation tag @title and @author is only allowed on contract definitions. It will be disallowed in 0.7.0."); |
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.
Please wrap this line.
0a38ec8
to
fc8b934
Compare
- adds natspec generation for state variables. - exports structured docs for state variables to JSON.
fc8b934
to
af8bb5f
Compare
Fixes #3418.
replaces #8399