mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8806 from ethereum/natspec-constructor
[BREAKING] Natspec constructor and functions have consistent userdoc
This commit is contained in:
commit
dd7d63925a
@ -11,7 +11,7 @@ Compiler Features:
|
|||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
* NatSpec: Constructors and functions have consistent userdoc output.
|
||||||
|
|
||||||
### 0.6.8 (unreleased)
|
### 0.6.8 (unreleased)
|
||||||
|
|
||||||
|
@ -42,8 +42,12 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef)
|
|||||||
{
|
{
|
||||||
string value = extractDoc(constructorDefinition->annotation().docTags, "notice");
|
string value = extractDoc(constructorDefinition->annotation().docTags, "notice");
|
||||||
if (!value.empty())
|
if (!value.empty())
|
||||||
|
{
|
||||||
// add the constructor, only if we have any documentation to add
|
// add the constructor, only if we have any documentation to add
|
||||||
methods["constructor"] = Json::Value(value);
|
Json::Value user;
|
||||||
|
user["notice"] = Json::Value(value);
|
||||||
|
methods["constructor"] = user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string notice = extractDoc(_contractDef.annotation().docTags, "notice");
|
string notice = extractDoc(_contractDef.annotation().docTags, "notice");
|
||||||
|
@ -849,16 +849,18 @@ BOOST_AUTO_TEST_CASE(dev_documenting_no_param_description)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(user_constructor)
|
BOOST_AUTO_TEST_CASE(user_constructor)
|
||||||
{
|
{
|
||||||
char const *sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
/// @notice this is a really nice constructor
|
/// @notice this is a really nice constructor
|
||||||
constructor(uint a, uint second) public { }
|
constructor(uint a, uint second) public { }
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
char const *natspec = R"ABCDEF({
|
char const* natspec = R"ABCDEF({
|
||||||
"methods" : {
|
"methods": {
|
||||||
"constructor" : "this is a really nice constructor"
|
"constructor" : {
|
||||||
|
"notice": "this is a really nice constructor"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})ABCDEF";
|
})ABCDEF";
|
||||||
|
|
||||||
@ -867,7 +869,7 @@ BOOST_AUTO_TEST_CASE(user_constructor)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(user_constructor_and_function)
|
BOOST_AUTO_TEST_CASE(user_constructor_and_function)
|
||||||
{
|
{
|
||||||
char const *sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
/// @notice this is a really nice constructor
|
/// @notice this is a really nice constructor
|
||||||
constructor(uint a, uint second) public { }
|
constructor(uint a, uint second) public { }
|
||||||
@ -876,12 +878,14 @@ BOOST_AUTO_TEST_CASE(user_constructor_and_function)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
|
||||||
char const *natspec = R"ABCDEF({
|
char const* natspec = R"ABCDEF({
|
||||||
"methods" : {
|
"methods" : {
|
||||||
"mul(uint256,uint256)" : {
|
"mul(uint256,uint256)" : {
|
||||||
"notice" : "another multiplier"
|
"notice" : "another multiplier"
|
||||||
},
|
},
|
||||||
"constructor" : "this is a really nice constructor"
|
"constructor" : {
|
||||||
|
"notice" : "this is a really nice constructor"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})ABCDEF";
|
})ABCDEF";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user