Uniform output in functions and constructor NatSpec

This commit is contained in:
hrkrshnn 2020-04-30 16:36:05 +05:30
parent e306fdc251
commit aa65e9423c
4 changed files with 19 additions and 11 deletions

View File

@ -11,7 +11,7 @@ Compiler Features:
Bugfixes:
* NatSpec: Constructors and functions have consistent userdoc output.
### 0.6.7 (unreleased)

View File

@ -71,7 +71,7 @@ So for the following contract snippet
the position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint256(4) . uint256(1))) + 1``::
pragma solidity >=0.4.0 <0.7.0;
pragma solidity >=0.4.0 <0.8.0;
contract C {
@ -171,7 +171,7 @@ value and reference types, types that are encoded packed, and nested types.
.. code::
pragma solidity >=0.4.0 <0.7.0;
pragma solidity >=0.4.0 <0.8.0;
contract A {
struct S {
uint128 a;

View File

@ -42,8 +42,12 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef)
{
string value = extractDoc(constructorDefinition->annotation().docTags, "notice");
if (!value.empty())
{
// 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");

View File

@ -858,7 +858,9 @@ BOOST_AUTO_TEST_CASE(user_constructor)
char const* natspec = R"ABCDEF({
"methods": {
"constructor" : "this is a really nice constructor"
"constructor" : {
"notice": "this is a really nice constructor"
}
}
})ABCDEF";
@ -881,7 +883,9 @@ BOOST_AUTO_TEST_CASE(user_constructor_and_function)
"mul(uint256,uint256)" : {
"notice" : "another multiplier"
},
"constructor" : "this is a really nice constructor"
"constructor" : {
"notice" : "this is a really nice constructor"
}
}
})ABCDEF";