Skip to content

Rule request: full NatSpec documentation #298

@fulldecent

Description

@fulldecent

Requesting a new rule and to enable it by default.

natspec-documentation

The following would trigger an error:

  • A public or external function which does not have a NatSpec comment
    • NatSpec comment does not have a @notice set
    • NatSpec comment does not have a @param for every parameter
    • NatSpec comment does not have a @return for every return
  • A public storage variable which does not have a NatSpec comment
    • NatSpec comment does not have a @notice set
    • NatSpec comment does not have a @param for every parameter
    • NatSpec comment does not have a @return for every return
  • An Error type which does not have a NatSpec comment
    • NatSpec commend does not have a @notice set

The Solidity project recommends the above. It is extremely useful. And few people do it. So it will be very helpful to add rules for it.

It is recommended that Solidity contracts are fully annotated using NatSpec for all public interfaces (everything in the ABI).

https://docs.soliditylang.org/en/v0.8.6/style-guide.html?highlight=style%20guide#natspec


As a bonus I am also requesting a separate rule that is OFF by default and which is more zealous.

Perhaps name this natspec-documentation-internal.

  • An internal function which does not have a NatSpec comment
    • NatSpec comment does not have a @param for every parameter
    • NatSpec comment does not have a @return for every return

Note that @notice is not required in this circumstance because that tag applies to "end users" whereas an internal function is useful only to contract developers.

Note that private functions are not included in this rule. This is because documentation for implementation details is always less important that documentation for an objects' surface area. If you like, this could be another rule natspec-documentation-private and should be default OFF.


I am a contributor to the Solidity NatSpec specification, the style guide and the above-referenced Solidity project recommendation. Ask me anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions