Skip to content

Commit

Permalink
Merge pull request #11662 from ethereum/docs-fix-highlighting-and-upg…
Browse files Browse the repository at this point in the history
…rade-pygments

[Docs] Fix highlighting and always use latest packages
  • Loading branch information
chriseth committed Jul 29, 2021
2 parents 7e1cfc1 + 0f7a185 commit 62727f3
Show file tree
Hide file tree
Showing 24 changed files with 115 additions and 93 deletions.
3 changes: 2 additions & 1 deletion docs/abi-spec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ Examples
Given the contract:

.. code-block:: solidity
:force:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.9.0;
Expand Down Expand Up @@ -657,7 +658,7 @@ As an example, the code
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.7.4 <0.9.0;
pragma solidity >=0.7.5 <0.9.0;
pragma abicoder v2;
contract Test {
Expand Down
3 changes: 2 additions & 1 deletion docs/cheatsheet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ Global Variables
Function Visibility Specifiers
==============================

::
.. code-block:: solidity
:force:
function myFunction() <visibility specifier> returns (bool) {
return true;
Expand Down
2 changes: 2 additions & 0 deletions docs/common-patterns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ The use of **function modifiers** makes these
restrictions highly readable.

.. code-block:: solidity
:force:
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
Expand Down Expand Up @@ -293,6 +294,7 @@ function finishes.
will run even if the function explicitly returns.

.. code-block:: solidity
:force:
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
Expand Down
2 changes: 1 addition & 1 deletion docs/contracts/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ four indexed arguments rather than three.
The use in the JavaScript API is as follows:

::
.. code-block:: javascript
var abi = /* abi as generated by the compiler */;
var ClientReceipt = web3.eth.contract(abi);
Expand Down
2 changes: 1 addition & 1 deletion docs/contracts/function-modifiers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if they are marked ``virtual``. For details, please see
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.7.0 <0.9.0;
pragma solidity >=0.7.1 <0.9.0;
contract owned {
constructor() { owner = payable(msg.sender); }
Expand Down
2 changes: 1 addition & 1 deletion docs/contracts/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ that call them, similar to internal library functions.
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.7.0 <0.9.0;
pragma solidity >=0.7.1 <0.9.0;
function sum(uint[] memory _arr) pure returns (uint s) {
for (uint i = 0; i < _arr.length; i++)
Expand Down
1 change: 1 addition & 0 deletions docs/contracts/libraries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ internal functions in libraries in order to implement
custom types without the overhead of external function calls:

.. code-block:: solidity
:force:
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
Expand Down
3 changes: 2 additions & 1 deletion docs/control-structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ The following example shows how you can use ``require`` to check conditions on i
and ``assert`` for internal error checking.

.. code-block:: solidity
:force:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.9.0;
Expand Down Expand Up @@ -786,7 +787,7 @@ A failure in an external call can be caught using a try/catch statement, as foll
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.8.0;
pragma solidity >=0.8.1;
interface DataFeed { function getData(address token) external returns (uint value); }
Expand Down
1 change: 1 addition & 0 deletions docs/examples/blind-auction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ invalid bids.


.. code-block:: solidity
:force:
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
Expand Down
12 changes: 6 additions & 6 deletions docs/internals/optimizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ operation where ``unused = 0``, ``undecided = 1`` and ``used = 2``.

The proper way would be to compute

::
.. code-block:: none
max(s, f(s), f(f(s)), f(f(f(s))), ...)
Expand All @@ -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

::
.. code-block:: none
max(s, f(s), f(f(s))) = max(s, f(s), f(f(s)), f(f(f(s))), ...).
Expand Down Expand Up @@ -1263,7 +1263,7 @@ Reverses the transformation of ForLoopConditionIntoBody.

For any movable ``c``, it turns

::
.. code-block:: none
for { ... } 1 { ... } {
if iszero(c) { break }
Expand All @@ -1272,15 +1272,15 @@ For any movable ``c``, it turns
into

::
.. code-block:: none
for { ... } c { ... } {
...
}
and it turns

::
.. code-block:: none
for { ... } 1 { ... } {
if c { break }
Expand All @@ -1289,7 +1289,7 @@ and it turns
into

::
.. code-block:: none
for { ... } iszero(c) { ... } {
...
Expand Down
8 changes: 6 additions & 2 deletions docs/introduction-to-smart-contracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
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; }
Expand All @@ -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
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) {
return balances[_account];
Expand Down
17 changes: 9 additions & 8 deletions docs/ir/ir-breaking-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hiding new and different behavior in existing code.
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.7.0;
pragma solidity >=0.7.1;
contract C {
struct S {
Expand Down Expand Up @@ -80,7 +80,7 @@ This causes differences in some contracts, for example:
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.7.0;
pragma solidity >=0.7.1;
contract A {
uint x;
Expand All @@ -104,7 +104,7 @@ This causes differences in some contracts, for example:
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.8.0;
pragma solidity >=0.8.1;
contract C {
bytes x;
Expand Down Expand Up @@ -135,7 +135,7 @@ This causes differences in some contracts, for example:
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.8.0;
pragma solidity >=0.8.1;
contract C {
function preincr_u8(uint8 _a) public pure returns (uint8) {
return ++_a + _a;
Expand All @@ -155,7 +155,7 @@ This causes differences in some contracts, for example:
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.8.0;
pragma solidity >=0.8.1;
contract C {
function add(uint8 _a, uint8 _b) public pure returns (uint8) {
return _a + _b;
Expand All @@ -174,10 +174,10 @@ This causes differences in some contracts, for example:
and left-to-right by the new code generator.
For example:

::
.. code-block:: solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.8.0;
pragma solidity >=0.8.1;
contract C {
function f() public pure returns (uint256 aMod, uint256 mMod) {
uint256 x = 3;
Expand Down Expand Up @@ -250,9 +250,10 @@ The new code generator performs cleanup after any operation that can result in d
For example:

.. code-block:: solidity
:force:
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.8.0;
pragma solidity >=0.8.1;
contract C {
function f(uint8 _a) public pure returns (uint _r1, uint _r2)
{
Expand Down
10 changes: 5 additions & 5 deletions docs/layout-of-source-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

::
.. code-block:: solidity
import "filename";
Expand All @@ -195,15 +195,15 @@ symbols explicitly.
The following example creates a new global symbol ``symbolName`` whose members are all
the global symbols from ``"filename"``:

::
.. code-block:: solidity
import * as symbolName from "filename";
which results in all global symbols being available in the format ``symbolName.symbol``.

A variant of this syntax that is not part of ES6, but possibly useful is:

::
.. code-block:: solidity
import "filename" as symbolName;
Expand All @@ -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
``symbol1`` and ``symbol2`` from inside ``"filename"``, respectively.

::
.. code-block:: solidity
import {symbol1 as alias, symbol2} from "filename";
Expand Down Expand Up @@ -253,7 +253,7 @@ Comments

Single-line comments (``//``) and multi-line comments (``/*...*/``) are possible.

::
.. code-block:: solidity
// This is a single-line comment.
Expand Down

0 comments on commit 62727f3

Please sign in to comment.