mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
docs: Replace a few remaining ::
blocks with .. code-block::
This commit is contained in:
parent
b513ca1f7e
commit
f3a5c27852
@ -158,7 +158,8 @@ Global Variables
|
|||||||
Function Visibility Specifiers
|
Function Visibility Specifiers
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
::
|
.. code-block:: solidity
|
||||||
|
:force:
|
||||||
|
|
||||||
function myFunction() <visibility specifier> returns (bool) {
|
function myFunction() <visibility specifier> returns (bool) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -97,7 +97,7 @@ four indexed arguments rather than three.
|
|||||||
|
|
||||||
The use in the JavaScript API is as follows:
|
The use in the JavaScript API is as follows:
|
||||||
|
|
||||||
::
|
.. code-block:: javascript
|
||||||
|
|
||||||
var abi = /* abi as generated by the compiler */;
|
var abi = /* abi as generated by the compiler */;
|
||||||
var ClientReceipt = web3.eth.contract(abi);
|
var ClientReceipt = web3.eth.contract(abi);
|
||||||
|
@ -696,7 +696,7 @@ operation where ``unused = 0``, ``undecided = 1`` and ``used = 2``.
|
|||||||
|
|
||||||
The proper way would be to compute
|
The proper way would be to compute
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
max(s, f(s), f(f(s)), f(f(f(s))), ...)
|
max(s, f(s), f(f(s)), f(f(f(s))), ...)
|
||||||
|
|
||||||
@ -705,7 +705,7 @@ iterating it has to reach a cycle after at most three iterations,
|
|||||||
and thus ``f(f(f(s)))`` has to equal one of ``s``, ``f(s)``, or ``f(f(s))``
|
and thus ``f(f(f(s)))`` has to equal one of ``s``, ``f(s)``, or ``f(f(s))``
|
||||||
and thus
|
and thus
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
max(s, f(s), f(f(s))) = max(s, f(s), f(f(s)), f(f(f(s))), ...).
|
max(s, f(s), f(f(s))) = max(s, f(s), f(f(s)), f(f(f(s))), ...).
|
||||||
|
|
||||||
@ -1263,7 +1263,7 @@ Reverses the transformation of ForLoopConditionIntoBody.
|
|||||||
|
|
||||||
For any movable ``c``, it turns
|
For any movable ``c``, it turns
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
for { ... } 1 { ... } {
|
for { ... } 1 { ... } {
|
||||||
if iszero(c) { break }
|
if iszero(c) { break }
|
||||||
@ -1272,7 +1272,7 @@ For any movable ``c``, it turns
|
|||||||
|
|
||||||
into
|
into
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
for { ... } c { ... } {
|
for { ... } c { ... } {
|
||||||
...
|
...
|
||||||
@ -1280,7 +1280,7 @@ into
|
|||||||
|
|
||||||
and it turns
|
and it turns
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
for { ... } 1 { ... } {
|
for { ... } 1 { ... } {
|
||||||
if c { break }
|
if c { break }
|
||||||
@ -1289,7 +1289,7 @@ and it turns
|
|||||||
|
|
||||||
into
|
into
|
||||||
|
|
||||||
::
|
.. code-block:: none
|
||||||
|
|
||||||
for { ... } iszero(c) { ... } {
|
for { ... } iszero(c) { ... } {
|
||||||
...
|
...
|
||||||
|
@ -140,7 +140,9 @@ of a keypair belonging to :ref:`external accounts<accounts>`.
|
|||||||
The keyword ``public`` automatically generates a function that allows you to access the current value of the state
|
The keyword ``public`` automatically generates a function that allows you to access the current value of the state
|
||||||
variable from outside of the contract. Without this keyword, other contracts have no way to access the variable.
|
variable from outside of the contract. Without this keyword, other contracts have no way to access the variable.
|
||||||
The code of the function generated by the compiler is equivalent
|
The code of the function generated by the compiler is equivalent
|
||||||
to the following (ignore ``external`` and ``view`` for now)::
|
to the following (ignore ``external`` and ``view`` for now):
|
||||||
|
|
||||||
|
.. code-block:: solidity
|
||||||
|
|
||||||
function minter() external view returns (address) { return minter; }
|
function minter() external view returns (address) { return minter; }
|
||||||
|
|
||||||
@ -162,7 +164,9 @@ even better, keep a list, or use a more suitable data type.
|
|||||||
|
|
||||||
The :ref:`getter function<getter-functions>` created by the ``public`` keyword
|
The :ref:`getter function<getter-functions>` created by the ``public`` keyword
|
||||||
is more complex in the case of a mapping. It looks like the
|
is more complex in the case of a mapping. It looks like the
|
||||||
following::
|
following:
|
||||||
|
|
||||||
|
.. code-block:: solidity
|
||||||
|
|
||||||
function balances(address _account) external view returns (uint) {
|
function balances(address _account) external view returns (uint) {
|
||||||
return balances[_account];
|
return balances[_account];
|
||||||
|
@ -174,7 +174,7 @@ This causes differences in some contracts, for example:
|
|||||||
and left-to-right by the new code generator.
|
and left-to-right by the new code generator.
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
::
|
.. code-block:: solidity
|
||||||
|
|
||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
pragma solidity >0.8.0;
|
pragma solidity >0.8.0;
|
||||||
|
@ -180,7 +180,7 @@ a `default export <https://developer.mozilla.org/en-US/docs/web/javascript/refer
|
|||||||
|
|
||||||
At a global level, you can use import statements of the following form:
|
At a global level, you can use import statements of the following form:
|
||||||
|
|
||||||
::
|
.. code-block:: solidity
|
||||||
|
|
||||||
import "filename";
|
import "filename";
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ symbols explicitly.
|
|||||||
The following example creates a new global symbol ``symbolName`` whose members are all
|
The following example creates a new global symbol ``symbolName`` whose members are all
|
||||||
the global symbols from ``"filename"``:
|
the global symbols from ``"filename"``:
|
||||||
|
|
||||||
::
|
.. code-block:: solidity
|
||||||
|
|
||||||
import * as symbolName from "filename";
|
import * as symbolName from "filename";
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ which results in all global symbols being available in the format ``symbolName.s
|
|||||||
|
|
||||||
A variant of this syntax that is not part of ES6, but possibly useful is:
|
A variant of this syntax that is not part of ES6, but possibly useful is:
|
||||||
|
|
||||||
::
|
.. code-block:: solidity
|
||||||
|
|
||||||
import "filename" as symbolName;
|
import "filename" as symbolName;
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ If there is a naming collision, you can rename symbols while importing. For exam
|
|||||||
the code below creates new global symbols ``alias`` and ``symbol2`` which reference
|
the code below creates new global symbols ``alias`` and ``symbol2`` which reference
|
||||||
``symbol1`` and ``symbol2`` from inside ``"filename"``, respectively.
|
``symbol1`` and ``symbol2`` from inside ``"filename"``, respectively.
|
||||||
|
|
||||||
::
|
.. code-block:: solidity
|
||||||
|
|
||||||
import {symbol1 as alias, symbol2} from "filename";
|
import {symbol1 as alias, symbol2} from "filename";
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ Comments
|
|||||||
|
|
||||||
Single-line comments (``//``) and multi-line comments (``/*...*/``) are possible.
|
Single-line comments (``//``) and multi-line comments (``/*...*/``) are possible.
|
||||||
|
|
||||||
::
|
.. code-block:: solidity
|
||||||
|
|
||||||
// This is a single-line comment.
|
// This is a single-line comment.
|
||||||
|
|
||||||
|
@ -147,7 +147,9 @@ the mapping ``{"ipfs": <IPFS hash>, "solc": <compiler version>}`` is stored
|
|||||||
contain more keys (see below) and the beginning of that
|
contain more keys (see below) and the beginning of that
|
||||||
encoding is not easy to find, its length is added in a two-byte big-endian
|
encoding is not easy to find, its length is added in a two-byte big-endian
|
||||||
encoding. The current version of the Solidity compiler usually adds the following
|
encoding. The current version of the Solidity compiler usually adds the following
|
||||||
to the end of the deployed bytecode::
|
to the end of the deployed bytecode
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
0xa2
|
0xa2
|
||||||
0x64 'i' 'p' 'f' 's' 0x58 0x22 <34 bytes IPFS hash>
|
0x64 'i' 'p' 'f' 's' 0x58 0x22 <34 bytes IPFS hash>
|
||||||
|
@ -180,7 +180,7 @@ Direct Imports
|
|||||||
|
|
||||||
An import that does not start with ``./`` or ``../`` is a *direct import*.
|
An import that does not start with ``./`` or ``../`` is a *direct import*.
|
||||||
|
|
||||||
::
|
.. code-block:: solidity
|
||||||
|
|
||||||
import "/project/lib/util.sol"; // source unit name: /project/lib/util.sol
|
import "/project/lib/util.sol"; // source unit name: /project/lib/util.sol
|
||||||
import "lib/util.sol"; // source unit name: lib/util.sol
|
import "lib/util.sol"; // source unit name: lib/util.sol
|
||||||
|
@ -410,7 +410,9 @@ No:
|
|||||||
|
|
||||||
spam( ham[ 1 ], Coin( { name: "ham" } ) );
|
spam( ham[ 1 ], Coin( { name: "ham" } ) );
|
||||||
|
|
||||||
Exception::
|
Exception:
|
||||||
|
|
||||||
|
.. code-block:: solidity
|
||||||
|
|
||||||
function singleLine() public { spam(); }
|
function singleLine() public { spam(); }
|
||||||
|
|
||||||
|
@ -534,7 +534,7 @@ It starts with a newline byte, followed by a double quote, a single
|
|||||||
quote a backslash character and then (without separator) the
|
quote a backslash character and then (without separator) the
|
||||||
character sequence ``abcdef``.
|
character sequence ``abcdef``.
|
||||||
|
|
||||||
::
|
.. code-block:: solidity
|
||||||
|
|
||||||
"\n\"\'\\abc\
|
"\n\"\'\\abc\
|
||||||
def"
|
def"
|
||||||
|
@ -41,7 +41,7 @@ Base Path and Import Remapping
|
|||||||
The commandline compiler will automatically read imported files from the filesystem, but
|
The commandline compiler will automatically read imported files from the filesystem, but
|
||||||
it is also possible to provide :ref:`path redirects <import-remapping>` using ``prefix=path`` in the following way:
|
it is also possible to provide :ref:`path redirects <import-remapping>` using ``prefix=path`` in the following way:
|
||||||
|
|
||||||
::
|
.. code-block:: bash
|
||||||
|
|
||||||
solc github.com/ethereum/dapp-bin/=/usr/local/lib/dapp-bin/ file.sol
|
solc github.com/ethereum/dapp-bin/=/usr/local/lib/dapp-bin/ file.sol
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user