The Vyper Domain
Directives
The Vyper domain (name vy) provides the following directives:
- .. vy:contract:: name
This directive marks the beginning of the description of a contract.
options
- :synopsis: purpose (text)
A single sentence describing the purpose of the contract.
- .. vy:currentcontract:: name
This directive tells Sphinx that the objects documented from here are in the given contract (like
vy:contract), but it will not create index entries. This is helpful in situations where documentation for objects in a contract are spread over multiple files or sections.
- .. vy:enum:: name
Describes an enum.
Info Fields
element: Description of an element.
.. vy:enum:: Roles :element Admin: An account with special privileges. :element Custodian: An account with privilege to call custodial functions. :element User: An account allowed to call user-facing functions.
This will render like this:
- Roles
- Elements:
Admin – An account with special privileges.
Custodian – An account with privilege to call custodial functions.
User – An account allowed to call user-facing functions.
- .. vy:event:: name
Describes an event.
Info Fields
topic: Description of an indexed parameter.topictype: Type of a topic.data: Description of a non-indexed parameter.datatype: Type of data.
.. vy:event:: Transfer :topic address sender: The account tokens originated from. :topic receiver: The account tokens were credited to. :topictype receiver: address :data uint256 value: The amount of tokens transferred.
This will render like this:
- Transfer
- Topics:
sender (address) – The account tokens originated from.
receiver (address) – The account tokens were credited to.
- Data:
value (uint256) – The amount of tokens transferred.
- .. vy:struct:: name
Describes a struct.
Info Fields
member: Description of a member.membertype: Type of a member.
.. vy:struct:: Point :member int256 x: The x-coordinate. :member y: The y-coordinate. :membertype y: int256
This will render like this:
- Point
- Members:
x (int256) – The x-coordinate.
y (int256) – The y-coordinate.
- .. vy:variable:: name
Describes a constant, immutable, or a storage variable.
options
- :type: type of the variable (text)
- :value: value of the variable (text)
.. vy:variable:: SIZE :type: uint256 :value: 42 .. vy:variable:: point :type: Point
This will render like this:
- SIZE: uint256 = 42
- point: Point
- .. vy:function:: name
Describes a function.
Info Fields
param,parameter,arg,argument: Description of a parameter.paramtype,type: Type of a parameter.revert,reverts,raises,except,exception: Description of arevert case.
returns,return,retval: Description of the return value.rtype: Return type.
.. vy:function:: main(_x: uint256, _y: uint32) -> uint8 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. :param uint256 _x: The seed value. :param _y: A salt value. :type _y: uint32 :returns: The value after computation. :rtype: uint8
This will render like this:
- main(_x: uint256, _y: uint32) uint8
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
- Parameters:
_x (uint256) – The seed value.
_y (uint32) – A salt value.
- Returns:
The value after computation.
- Return type:
uint8
Roles
The following roles are provided for cross-referencing objects and are hyperlinked if a matching identifier is found:
Note
For roles other than vy:contract, the target is specified as contract.name,
for example:
... :vy:func:`ERC20.transfer` emits the :vy:event:`ERC20.Transfer` event.
- :vy:contract:
Reference a contract.
- :vy:enum:
Reference an enum.
- :vy:event:
Reference an event.
- :vy:struct:
Reference a struct.
- :vy:var:
Reference a variable.
- :vy:func:
Reference a function.
Indices
The Vyper Contract Index is available by linking to vy-contractindex, like so:
:ref:`vy-contractindex`