From 9904dc386d30b6b8a6facb43d403a03269979237 Mon Sep 17 00:00:00 2001 From: holgerd77 Date: Thu, 18 Feb 2016 10:34:23 +0100 Subject: Use code blocks for import syntax explanations for better readability --- docs/layout-of-source-files.rst | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'docs/layout-of-source-files.rst') diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index b795d154..3fb64635 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -17,15 +17,33 @@ Solidity supports import statements that are very similar to those available in At a global level, you can use import statements of the following form: -`import "filename";` will import all global symbols from "filename" (and symbols imported there) into the current global scope (different than in ES6 but backwards-compatible for Solidity). +:: -`import * as symbolName from "filename";` creates a new global symbol `symbolName` whose members are all the global symbols from `"filename"`. + import "filename"; -`import {symbol1 as alias, symbol2} from "filename";` creates new global symbols `alias` and `symbol2` which reference `symbol1` and `symbal2` from `"filename"`, respectively. +...will import all global symbols from "filename" (and symbols imported there) into the +current global scope (different than in ES6 but backwards-compatible for Solidity). + +:: + + import * as symbolName from "filename"; + +...creates a new global symbol `symbolName` whose members are all the global symbols from `"filename"`. + +:: + + import {symbol1 as alias, symbol2} from "filename"; + +...creates new global symbols `alias` and `symbol2` which reference `symbol1` and `symbol2` +from `"filename"`, respectively. Another syntax is not part of ES6, but probably convenient: -`import "filename" as symbolName;` is equivalent to `import * as symbolName from "filename";`. +:: + + import "filename" as symbolName; + +...is equivalent to `import * as symbolName from "filename";`. Paths ----- -- cgit v1.2.3 From 0e44481b0fa2a40c756602bd779b871ad6fcd347 Mon Sep 17 00:00:00 2001 From: holgerd77 Date: Thu, 18 Feb 2016 11:00:33 +0100 Subject: Code blocks for compiler use section --- docs/layout-of-source-files.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'docs/layout-of-source-files.rst') diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index 3fb64635..07934560 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -34,8 +34,7 @@ current global scope (different than in ES6 but backwards-compatible for Solidit import {symbol1 as alias, symbol2} from "filename"; -...creates new global symbols `alias` and `symbol2` which reference `symbol1` and `symbol2` -from `"filename"`, respectively. +...creates new global symbols `alias` and `symbol2` which reference `symbol1` and `symbol2` from `"filename"`, respectively. Another syntax is not part of ES6, but probably convenient: @@ -83,11 +82,15 @@ So as an example, if you clone `github.com/ethereum/dapp-bin/` locally to `/usr/local/dapp-bin`, you can use the following in your source file: -`import "github.com/ethereum/dapp-bin/library/iterable_mapping.sol" as it_mapping;` +:: + + import "github.com/ethereum/dapp-bin/library/iterable_mapping.sol" as it_mapping; and then run the compiler as -`solc github.com/ethereum/dapp-bin/=/usr/local/dapp-bin/ source.sol` +.. code-block:: shell + + solc github.com/ethereum/dapp-bin/=/usr/local/dapp-bin/ source.sol Note that solc only allows you to include files from certain directories: They have to be in the directory (or subdirectory) of one of the explicitly -- cgit v1.2.3 From 688313cc5131a8aa156c2837a3629842e17ec93c Mon Sep 17 00:00:00 2001 From: holgerd77 Date: Thu, 18 Feb 2016 11:08:20 +0100 Subject: Comment code examples --- docs/layout-of-source-files.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'docs/layout-of-source-files.rst') diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index 07934560..48ecfb09 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -119,6 +119,16 @@ Comments Single-line comments (`//`) and multi-line comments (`/*...*/`) are possible. +:: + + // This is a single-line comment. + + /* + This is a + multi-line comment. + */ + + There are special types of comments called natspec comments (documentation yet to be written). These are introduced by triple-slash comments (`///`) or using double asterisks (`/** ... */`). -- cgit v1.2.3