Adds structured docs for variable declarations.

- adds natspec generation for state variables.
- exports structured docs for state variables to JSON.
This commit is contained in:
Erik Kundt
2020-05-19 11:01:52 -05:00
committed by Alexander Arlt
parent 3e8b9bdb1c
commit 7d37ed4531
11 changed files with 128 additions and 5 deletions
+39
View File
@@ -204,6 +204,45 @@ BOOST_AUTO_TEST_CASE(dev_and_user_no_doc)
checkNatspec(sourceCode, "test", userNatspec, true);
}
BOOST_AUTO_TEST_CASE(dev_state_variable)
{
char const* sourceCode = R"(
contract test {
/// @dev Public accessor for the internal state
/// @notice Keeps track of the internal state
uint public state;
}
)";
char const* natspec = "{"
"\"methods\":{"
" \"state()\":{ \n"
" \"details\": \"Public accessor for the internal state\",\n"
" }\n"
"}}";
checkNatspec(sourceCode, "test", natspec, false);
}
BOOST_AUTO_TEST_CASE(user_state_variable)
{
char const* sourceCode = R"(
contract test {
/// @notice Keeps track of the internal state
uint public state;
}
)";
char const* natspec = "{"
"\"methods\":{"
" \"state()\":{ \n"
" \"notice\": \"Keeps track of the internal state\",n"
" }\n"
"}}";
checkNatspec(sourceCode, "test", natspec, true);
}
BOOST_AUTO_TEST_CASE(dev_desc_after_nl)
{
char const* sourceCode = R"(
@@ -0,0 +1,9 @@
contract C {
/// @title example of title
/// @author example of author
/// @notice example of notice
/// @dev example of dev
/// @param example of param
/// @return example of return
uint public state;
}
@@ -0,0 +1,13 @@
contract C {
function f() public pure returns (uint) {
/// @title example of title
/// @author example of author
/// @notice example of notice
/// @dev example of dev
/// @param example of param
/// @return example of return
uint state = 42;
return state;
}
}
// ----