Formatting Solidity Elements¶
-
.. sol:contract::Name is Parent1, Parent2, ...¶ -
.. sol:interface::Name is Parent1, Parent2, ...¶ -
.. sol:library::Name¶ These directives describe top-level Solidity objects. The following:
.. sol:library:: SafeMath Provides arithemetic operations guarded against overflow
renders as
-
library
SafeMath¶ Provides arithemetic operations guarded against overflow
Likewise, the following:
.. sol:contract:: MintableBurnableToken is MintableToken, StandardBurnableToken A token which can both be minted and burnt.
renders as
-
contract
MintableBurnableTokenis MintableToken, StandardBurnableToken¶ A token which can both be minted and burnt.
-
library
-
.. sol:statevar::type visibility name¶ State variables in Solidity:
.. sol:statevar:: int128 public widgetSocket A socket for a widget.
yields
-
int128 public
widgetSocket¶ A socket for a widget.
Visibility modifiers are optional and include the following:
- public
- private
- internal
-
int128 public
-
.. sol:constructor::(type mod arg1, type mod arg2, ...) mod1 mod2 ...¶ Constructors for contracts. May be used in the context of a
sol:contractdirective. For example,.. sol:contract:: FooFactory Produces instances of Foo. .. sol:constructor:: (uint a, int b, bytes32 c) public restrictedTo(a) Creates a FooFactory, initializing with supplied parameters.
yields
-
.. sol:function::name(type mod arg1, ...) mod1 ... returns (type r1, ...)¶ Solidity functions. May be used in the context of a
sol:contract,sol:library, orsol:interfacedirective. For example,.. sol:interface:: ERC20 .. sol:function:: balanceOf(address tokenOwner) \ public constant returns (uint balance) Get the token balance for account ``tokenOwner``.
yields
-
.. sol:modifier::name(type mod arg1, ...)¶ Solidity function modifiers. For example:
.. sol:contract:: Ownable .. sol:modifier:: onlyOwner() Throws if called by any account other than the owner.
yields
-
.. sol:event::name(type mod arg1, ...)¶ Solidity events. For example:
.. sol:contract:: RefundVault is Ownable .. sol:event:: Refunded(address indexed beneficiary, uint256 weiAmount) Emitted when ``weiAmount`` gets refunded to a ``beneficiary``.
yields
-
.. sol:struct::Name¶ Solidity structs. Members of the struct are represented by a
memberfield. For example:.. sol:struct:: DreamMachine Some archetypical madness. :member uint widget: Funky lil' widget. :member FunkUtils.Orientation orientation: Which way the machine is pointing. :member typelessThing: Type information is optional.
yields
-
struct
DreamMachine¶ Some archetypical madness.
Members: - widget (uint) – Funky lil’ widget.
- orientation (FunkUtils.Orientation) – Which way the machine is pointing.
- typelessThing – Type information is optional.
-
struct
-
.. sol:enum::Name¶ Solidity enum definitions. Like
struct, members are represented by amemberfield, but for enums, this field is typeless. For example:.. sol:enum:: Direction Which way to go. :member North: Where Santa's at. :member South: Where penguins're at. :member East: Get tricky. :member West: Get funky.
yields
-
enum
Direction¶ Which way to go.
Members: - North – Where Santa’s at.
- South – Where penguins’re at.
- East – Get tricky.
- West – Get funky.
-
enum