docs: Fix syntax errors in JSON snippets and enable JavaScript highlighting for them

This commit is contained in:
Kamil Śliwak 2021-07-14 18:53:15 +02:00
parent f3a5c27852
commit 235a39eaef
3 changed files with 51 additions and 52 deletions

View File

@ -31,24 +31,24 @@ reduce whitespace to a minimum and sort the keys of all objects to arrive at a
unique formatting. Comments are not permitted and used here only for unique formatting. Comments are not permitted and used here only for
explanatory purposes. explanatory purposes.
.. code-block:: none .. code-block:: javascript
{ {
// Required: The version of the metadata format // Required: The version of the metadata format
version: "1", "version": "1",
// Required: Source code language, basically selects a "sub-version" // Required: Source code language, basically selects a "sub-version"
// of the specification // of the specification
language: "Solidity", "language": "Solidity",
// Required: Details about the compiler, contents are specific // Required: Details about the compiler, contents are specific
// to the language. // to the language.
compiler: { "compiler": {
// Required for Solidity: Version of the compiler // Required for Solidity: Version of the compiler
version: "0.4.6+commit.2dabbdf0.Emscripten.clang", "version": "0.4.6+commit.2dabbdf0.Emscripten.clang",
// Optional: Hash of the compiler binary which produced this output // Optional: Hash of the compiler binary which produced this output
keccak256: "0x123..." "keccak256": "0x123..."
}, },
// Required: Compilation source files/source units, keys are file names // Required: Compilation source files/source units, keys are file names
sources: "sources":
{ {
"myFile.sol": { "myFile.sol": {
// Required: keccak256 hash of the source file // Required: keccak256 hash of the source file
@ -68,59 +68,59 @@ explanatory purposes.
} }
}, },
// Required: Compiler settings // Required: Compiler settings
settings: "settings":
{ {
// Required for Solidity: Sorted list of remappings // Required for Solidity: Sorted list of remappings
remappings: [ ":g=/dir" ], "remappings": [ ":g=/dir" ],
// Optional: Optimizer settings. The fields "enabled" and "runs" are deprecated // Optional: Optimizer settings. The fields "enabled" and "runs" are deprecated
// and are only given for backwards-compatibility. // and are only given for backwards-compatibility.
optimizer: { "optimizer": {
enabled: true, "enabled": true,
runs: 500, "runs": 500,
details: { "details": {
// peephole defaults to "true" // peephole defaults to "true"
peephole: true, "peephole": true,
// inliner defaults to "true" // inliner defaults to "true"
inliner: true, "inliner": true,
// jumpdestRemover defaults to "true" // jumpdestRemover defaults to "true"
jumpdestRemover: true, "jumpdestRemover": true,
orderLiterals: false, "orderLiterals": false,
deduplicate: false, "deduplicate": false,
cse: false, "cse": false,
constantOptimizer: false, "constantOptimizer": false,
yul: true, "yul": true,
// Optional: Only present if "yul" is "true" // Optional: Only present if "yul" is "true"
yulDetails: { "yulDetails": {
stackAllocation: false, "stackAllocation": false,
optimizerSteps: "dhfoDgvulfnTUtnIf..." "optimizerSteps": "dhfoDgvulfnTUtnIf..."
} }
} }
}, },
metadata: { "metadata": {
// Reflects the setting used in the input json, defaults to false // Reflects the setting used in the input json, defaults to false
useLiteralContent: true, "useLiteralContent": true,
// Reflects the setting used in the input json, defaults to "ipfs" // Reflects the setting used in the input json, defaults to "ipfs"
bytecodeHash: "ipfs" "bytecodeHash": "ipfs"
} },
// Required for Solidity: File and name of the contract or library this // Required for Solidity: File and name of the contract or library this
// metadata is created for. // metadata is created for.
compilationTarget: { "compilationTarget": {
"myFile.sol": "MyContract" "myFile.sol": "MyContract"
}, },
// Required for Solidity: Addresses for libraries used // Required for Solidity: Addresses for libraries used
libraries: { "libraries": {
"MyLib": "0x123123..." "MyLib": "0x123123..."
} }
}, },
// Required: Generated information about the contract. // Required: Generated information about the contract.
output: "output":
{ {
// Required: ABI definition of the contract // Required: ABI definition of the contract
abi: [ ... ], "abi": [/* ... */],
// Required: NatSpec user documentation of the contract // Required: NatSpec user documentation of the contract
userdoc: [ ... ], "userdoc": [/* ... */],
// Required: NatSpec developer documentation of the contract // Required: NatSpec developer documentation of the contract
devdoc: [ ... ], "devdoc": [/* ... */]
} }
} }

View File

@ -494,10 +494,9 @@ allowed) of <source>:<contract> pairs in the CLI:
and via the object ``settings.modelChecker.contracts`` in the :ref:`JSON input<compiler-api>`, and via the object ``settings.modelChecker.contracts`` in the :ref:`JSON input<compiler-api>`,
which has the following form: which has the following form:
.. code-block:: none .. code-block:: json
contracts "contracts": {
{
"source1.sol": ["contract1"], "source1.sol": ["contract1"],
"source2.sol": ["contract2", "contract3"] "source2.sol": ["contract2", "contract3"]
} }

View File

@ -134,12 +134,12 @@ On the command line, you can select the EVM version as follows:
In the :ref:`standard JSON interface <compiler-api>`, use the ``"evmVersion"`` In the :ref:`standard JSON interface <compiler-api>`, use the ``"evmVersion"``
key in the ``"settings"`` field: key in the ``"settings"`` field:
.. code-block:: none .. code-block:: javascript
{ {
"sources": { ... }, "sources": {/* ... */},
"settings": { "settings": {
"optimizer": { ... }, "optimizer": {/* ... */},
"evmVersion": "<VERSION>" "evmVersion": "<VERSION>"
} }
} }
@ -198,7 +198,7 @@ Comments are of course not permitted and used here only for explanatory purposes
Input Description Input Description
----------------- -----------------
.. code-block:: none .. code-block:: javascript
{ {
// Required: Source code language. Currently supported are "Solidity" and "Yul". // Required: Source code language. Currently supported are "Solidity" and "Yul".
@ -310,7 +310,7 @@ Input Description
// "debug" injects strings for compiler-generated internal reverts, implemented for ABI encoders V1 and V2 for now. // "debug" injects strings for compiler-generated internal reverts, implemented for ABI encoders V1 and V2 for now.
// "verboseDebug" even appends further information to user-supplied revert strings (not yet implemented) // "verboseDebug" even appends further information to user-supplied revert strings (not yet implemented)
"revertStrings": "default" "revertStrings": "default"
} },
// Metadata settings (optional) // Metadata settings (optional)
"metadata": { "metadata": {
// Use only literal content and not URLs (false by default) // Use only literal content and not URLs (false by default)
@ -331,7 +331,7 @@ Input Description
"myFile.sol": { "myFile.sol": {
"MyLib": "0x123123..." "MyLib": "0x123123..."
} }
} },
// The following can be used to select desired outputs based // The following can be used to select desired outputs based
// on file and contract names. // on file and contract names.
// If this field is omitted, then the compiler loads and does type checking, // If this field is omitted, then the compiler loads and does type checking,
@ -395,7 +395,7 @@ Input Description
"modelChecker": "modelChecker":
{ {
// Chose which contracts should be analyzed as the deployed one. // Chose which contracts should be analyzed as the deployed one.
contracts: "contracts":
{ {
"source1.sol": ["contract1"], "source1.sol": ["contract1"],
"source2.sol": ["contract2", "contract3"] "source2.sol": ["contract2", "contract3"]
@ -420,7 +420,7 @@ Input Description
Output Description Output Description
------------------ ------------------
.. code-block:: none .. code-block:: javascript
{ {
// Optional: not present if no errors/warnings were encountered // Optional: not present if no errors/warnings were encountered
@ -431,7 +431,7 @@ Output Description
"file": "sourceFile.sol", "file": "sourceFile.sol",
"start": 0, "start": 0,
"end": 100 "end": 100
], },
// Optional: Further locations (e.g. places of conflicting declarations) // Optional: Further locations (e.g. places of conflicting declarations)
"secondarySourceLocations": [ "secondarySourceLocations": [
{ {
@ -463,7 +463,7 @@ Output Description
// Identifier of the source (used in source maps) // Identifier of the source (used in source maps)
"id": 1, "id": 1,
// The AST object // The AST object
"ast": {}, "ast": {}
} }
}, },
// This contains the contract-level outputs. // This contains the contract-level outputs.
@ -476,7 +476,7 @@ Output Description
// See https://docs.soliditylang.org/en/develop/abi-spec.html // See https://docs.soliditylang.org/en/develop/abi-spec.html
"abi": [], "abi": [],
// See the Metadata Output documentation (serialised JSON string) // See the Metadata Output documentation (serialised JSON string)
"metadata": "{...}", "metadata": "{/* ... */}",
// User documentation (natspec) // User documentation (natspec)
"userdoc": {}, "userdoc": {},
// Developer documentation (natspec) // Developer documentation (natspec)
@ -484,7 +484,7 @@ Output Description
// Intermediate representation (string) // Intermediate representation (string)
"ir": "", "ir": "",
// See the Storage Layout documentation. // See the Storage Layout documentation.
"storageLayout": {"storage": [...], "types": {...} }, "storageLayout": {"storage": [/* ... */], "types": {/* ... */} },
// EVM-related outputs // EVM-related outputs
"evm": { "evm": {
// Assembly (string) // Assembly (string)
@ -514,14 +514,14 @@ Output Description
// contains a single Yul file. // contains a single Yul file.
"generatedSources": [{ "generatedSources": [{
// Yul AST // Yul AST
"ast": { ... } "ast": {/* ... */},
// Source file in its text form (may contain comments) // Source file in its text form (may contain comments)
"contents":"{ function abi_decode(start, end) -> data { data := calldataload(start) } }", "contents":"{ function abi_decode(start, end) -> data { data := calldataload(start) } }",
// Source file ID, used for source references, same "namespace" as the Solidity source files // Source file ID, used for source references, same "namespace" as the Solidity source files
"id": 2, "id": 2,
"language": "Yul", "language": "Yul",
"name": "#utility.yul" "name": "#utility.yul"
}] }],
// If given, this is an unlinked object. // If given, this is an unlinked object.
"linkReferences": { "linkReferences": {
"libraryFile.sol": { "libraryFile.sol": {
@ -535,7 +535,7 @@ Output Description
} }
}, },
"deployedBytecode": { "deployedBytecode": {
..., // The same layout as above. /* ..., */ // The same layout as above.
"immutableReferences": { "immutableReferences": {
// There are two references to the immutable with AST ID 3, both 32 bytes long. One is // There are two references to the immutable with AST ID 3, both 32 bytes long. One is
// at bytecode offset 42, the other at bytecode offset 80. // at bytecode offset 42, the other at bytecode offset 80.