Skip to content

wake.ir.meta.structured_documentation module #

StructuredDocumentation class #

Bases: SolidityAbc

Example

Lines 1-4 in the following example:

1
2
3
4
5
6
7
8
9
/// @title A simulator for trees
/// @author John
/// @notice You can use this contract for only the most basic simulation
/// @dev All function calls are currently implemented without side effects
contract Tree {
    function multiply(uint a) public pure returns(uint) {
        return a * 7;
    }
}

Source code in wake/ir/meta/structured_documentation.py
class StructuredDocumentation(SolidityAbc):
    """
    !!! example
        Lines 1-4 in the following example:
        ```solidity linenums="1"
        /// @title A simulator for trees
        /// @author John
        /// @notice You can use this contract for only the most basic simulation
        /// @dev All function calls are currently implemented without side effects
        contract Tree {
            function multiply(uint a) public pure returns(uint) {
                return a * 7;
            }
        }
        ```
    """

    _ast_node: SolcStructuredDocumentation
    _parent: Union[
        ContractDefinition,
        EnumDefinition,
        ErrorDefinition,
        EventDefinition,
        FunctionDefinition,
        ModifierDefinition,
        StructDefinition,
        VariableDeclaration,
    ]

    _text: str

    def __init__(
        self,
        init: IrInitTuple,
        structured_documentation: SolcStructuredDocumentation,
        parent: SolidityAbc,
    ):
        super().__init__(init, structured_documentation, parent)
        self._text = structured_documentation.text

    @property
    def parent(
        self,
    ) -> Union[
        ContractDefinition,
        EnumDefinition,
        ErrorDefinition,
        EventDefinition,
        FunctionDefinition,
        ModifierDefinition,
        StructDefinition,
        VariableDeclaration,
    ]:
        """
        Returns:
            Parent IR node.
        """
        return self._parent

    @property
    def text(self) -> str:
        """
        Does not include the leading `///` or `/**` and trailing `*/`.

        Returns:
            [NatSpec](https://docs.soliditylang.org/en/latest/natspec-format.html) documentation string.
        """
        return self._text

parent: Union[ContractDefinition, EnumDefinition, ErrorDefinition, EventDefinition, FunctionDefinition, ModifierDefinition, StructDefinition, VariableDeclaration] property #

text: str property #

Does not include the leading /// or /** and trailing */.

Returns:

Type Description
str

NatSpec documentation string.