Skip to content

Allow NatSpec comments for variables #3418

@fulldecent

Description

@fulldecent

Test case

pragma solidity ^0.5.0;

/// @title A simulator for Bug Bunny, the most famous Rabbit
/// @author Warned Bros
/// @notice You can use this contract for only the most basic simulation
/// @dev All function calls are currently implement without side effects
contract BugsBunny {
    /// @author Bob Clampett
    /// @notice Determine if Bugs will or will not accept given food
    /// @dev Food must be provided in UTF-8 format
    /// @param _food The name of a food to evaluate (English)
    /// @return true if Bugs will eat it, false otherwise
    function doesEat(string calldata _food) external pure returns (bool) {
        return keccak256(bytes(_food)) == keccak256("carrot");
    }
    
    /// @title example of title
    /// @author example of author
    /// @notice example of notice
    /// @dev example of dev
    /// @param example of param
    /// @return example of return
    string public constant name = "Bugs";
}

Run the command:

solc -o outputDirectory --userdoc --devdoc tmp.sol

Then test output with:

jq .methods outputDirectory/*

Expected outcome

Documentation is output for doesEat and name public functions.

Actual outcome

{
  "doesEat(string)": {
    "author": "Bob Clampett",
    "details": "Food must be provided in UTF-8 format",
    "params": {
      "_food": "The name of a food to evaluate (English)"
    },
    "return": "true if Bugs will eat it, false otherwise"
  }
}
{
  "doesEat(string)": {
    "notice": "Determine if Bugs will or will not accept given food"
  }
}

Follow on work

Metadata

Metadata

Assignees

Labels

language design :rage4:Any changes to the language, e.g. new features

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions