solidity-docgen
solidity-docgen copied to clipboard
Do not expect that first word in comment line is name of result variable
Consider following method and comment:
/// @return Some value
function foo() external view returns(uint256) {
return 0;
}
When it get parsed with parseNatSpec
function it parses Some
as response variable name and the rest as its description. But natspec
doesn't have any requirements on format of return
and it makes total sense to omit it at all when there is only one return value
There is a comment about its format:
If your function returns multiple values, like (int quotient, int remainder) then use multiple @return statements in the same format as the @param statements.
But their own example with Tree
shows that it only applies when function has more than one output value
Thanks for pointing this out. We're indeed assuming the wrong format in our parsing.
It seems that if the function declares names for return values (as in returns (uint a)
) then the NatSpec syntax expects the variable name, otherwise it doesn't.
Right, but it still should possible to add comment to function result, even if it's anonymous. It should be then somehing like:
result.name // undefined
result.description // 'Some value'
Yes, I was able to reproduce the behavior implemented by solc.