New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow NatSpec comments for variables #3418

Open
fulldecent opened this Issue Jan 21, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@fulldecent
Copy link
Contributor

fulldecent commented Jan 21, 2018

Test case

Run this in Remix.

pragma solidity ^0.4.19;

/// @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 _food) external pure returns (bool) {
        return keccak256(_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 bob = "h";
}

This produces the following output (see DETALS button):

{
  "compiler": {
    "version": "0.4.19+commit.c4cbbb05"
  },
  "language": "Solidity",
  "output": {
    "abi": [
      {
        "constant": true,
        "inputs": [
          {
            "name": "_food",
            "type": "string"
          }
        ],
        "name": "doesEat",
        "outputs": [
          {
            "name": "",
            "type": "bool"
          }
        ],
        "payable": false,
        "stateMutability": "pure",
        "type": "function"
      },
      {
        "constant": true,
        "inputs": [
          
        ],
        "name": "bob",
        "outputs": [
          {
            "name": "",
            "type": "string"
          }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
      }
    ],
    "devdoc": {
      "author": "Warned Bros",
      "methods": {
        "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"
        }
      },
      "title": "A simulator for Bug Bunny, the most famous Rabbit"
    },
    "userdoc": {
      "methods": {
        "doesEat(string)": {
          "notice": "Determine if Bugs will or will not accept given food"
        }
      }
    }
  },
  "settings": {
    "compilationTarget": {
      "browser\/spectest.sol": "BugsBunny"
    },
    "libraries": {
      
    },
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "remappings": [
      
    ]
  },
  "sources": {
    "browser\/spectest.sol": {
      "keccak256": "0xc4f3ff3717d60ca1d9b7897c745b3026b40ffbdf128f6dd852b0759e575fe870",
      "urls": [
        "bzzr:\/\/a99254b3d34e45acc19c8950b86a013c7a7fc3fe27e34385d0e834290e3f43a6"
      ]
    }
  },
  "version": 1
}

Discussion

Notice how the ABI (again, I hate this word choice) includes two functions. However the NatSpec is only accepted for the one function.

The issues

NatSpec parser should allow tags against variables.

Follow on work

@fulldecent fulldecent referenced this issue Jan 24, 2018

Merged

EIP-721 Non-Fungible Token Standard #841

14 of 14 tasks complete
@axic

This comment has been minimized.

Copy link
Member

axic commented Jan 29, 2018

This depends on accepting #3411 first.

@fulldecent

This comment has been minimized.

Copy link
Contributor

fulldecent commented Jan 30, 2018

#3411 is closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment