Prechádzať zdrojové kódy

Minor documentation fixes

Signed-off-by: Sean Young <sean@mess.org>
Sean Young 4 rokov pred
rodič
commit
2e7d612af3
4 zmenil súbory, kde vykonal 34 pridanie a 24 odobranie
  1. 2 3
      docs/index.rst
  2. 6 3
      docs/installing.rst
  3. 24 11
      docs/language.rst
  4. 2 7
      docs/running.rst

+ 2 - 3
docs/index.rst

@@ -1,8 +1,7 @@
 Solang Solidity Compiler
 ========================
 
-Welcome to the Solang Solidity Compiler, the portable Solidity compiler.
-Using Solang, you can compile smart contracts written in
+Welcome to the Solang Solidity Compiler. Using Solang, you can compile smart contracts written in
 `Solidity <https://en.wikipedia.org/wiki/Solidity>`_ for
 `Solana <https://www.solana.com/>`_,
 `Parity Substrate <https://substrate.dev/>`_, and
@@ -12,7 +11,7 @@ Using Solang, you can compile smart contracts written in
 
 Solang aims for source file compatibility with the Ethereum EVM Solidity compiler,
 version 0.7. Where differences exists, this is noted in the :ref:`language documentation <language>`.
-The repository can be found on `github <https://github.com/hyperledger-labs/solang>`_
+The source code repository can be found on `github <https://github.com/hyperledger-labs/solang>`_
 and we have a `channel #solang on chat.hyperledger.org <https://chat.hyperledger.org/channel/solang>`_, and
 a `channel #solang-solidity-compiler on Solana Discord <https://discordapp.com/invite/pquxPsq>`_.
 

+ 6 - 3
docs/installing.rst

@@ -30,7 +30,7 @@ There is a release `v0.1.8` tag and a `latest` tag:
 
 .. code-block:: bash
 
-	docker pull hyperledgerlabs/solang
+	docker pull hyperledgerlabs/solang:latest
 
 The Solang binary is stored at ``/usr/bin/solang`` in this image. The `latest` tag
 gets updated each time there is a commit to the main branch of the Solang git repository.
@@ -64,7 +64,10 @@ Installing the LLVM Libraries
 
 Solang needs a build of
 `llvm with some extra patches <https://github.com/solana-labs/llvm-project/>`_.
-You can either download the pre-built binaries from
+These patches make it possible to generate code for Solana, and fixes some
+concurrency issues in the lld linker.
+
+You can either download the pre-built libraries from
 `github <https://github.com/hyperledger-labs/solang/releases/tag/v0.1.8>`_
 or build your own from source. After that, you need to add the `bin` directory to your
 path, so that the build system of Solang can find the correct version of llvm to use.
@@ -125,7 +128,7 @@ you may need to consult. First if all clone our llvm repository:
 
 .. code-block:: bash
 
-	git clone --branch solana-rustc/12.0-2021-04-15 git://github.com/solana-labs/llvm-project
+	git clone --depth 1 --branch solana-rustc/12.0-2021-04-15 git://github.com/solana-labs/llvm-project
 	cd llvm-project
 
 Now run cmake to create the makefiles. Replace the *installdir* argument to ``CMAKE_INSTALL_PREFIX`` with with a directory where you would like to have llvm installed, and then run the build:

+ 24 - 11
docs/language.rst

@@ -64,11 +64,14 @@ as the file name.
 Imports
 _______
 
-The ``import`` directive is used to import from other Solidity files. This can be useful to
-keep a single definition in one file, which can be used in multiple other files. Solidity imports
-are somewhat similar to JavaScript ES6, however there is no export statement, or default export.
+The ``import`` directive is used to import items from other Solidity files. This can be useful to
+keep a single definition in one file, which can be used in other files. For example
+you could have an interface in one source file, which several contracts implement or use
+which are in other files. Solidity imports are somewhat similar to JavaScript ES6, however
+there is no export statement, or default export.
 
-The following can be imported:
+The following items are always exported, which means they can be imported into
+another file.
 
 - global constants
 - struct definitions
@@ -96,6 +99,16 @@ with this syntax.
 
     import "defines.sol";
 
+Another method for locating files is using import maps. This maps the first directory
+of an import path to a different location on the file system. Say you add
+the command line option ``--importmap @openzeppelin=/opt/openzeppelin-contracts/contracts``, then
+
+.. code-block::
+
+    import "openzeppelin/interfaces/IERC20.sol";
+
+will automatically map to `/opt/openzeppelin-contracts/contracts/interfaces/IERC20.sol`.
+
 Everything defined in `defines.sol` is now usable in your Solidity file. However, if something with the
 same name is defined in `defines.sol` and also in the current file, you will get a warning. Note that
 that it is legal to import the same file more than once.
@@ -108,9 +121,9 @@ a naming conflict.
 
     import {bar as baz,foo} from "defines.sol";
 
-Rather than renaming individual imports, it is also possible to make all the types in a file
+Rather than renaming individual imports, it is also possible to make all the items in a file
 available under a special import object. In this case, the `bar` defined in `defines.sol` can is
-now visible as `defs.bar`, and `foo` is `defs.foo`. As long as there is no previous type `defs`,
+now visible as `defs.bar`, and `foo` as `defs.foo`. As long as there is no previous item `defs`,
 there can be no naming conflict.
 
 .. code-block:: javascript
@@ -219,8 +232,8 @@ ________________________
 Solidity has a primitive type unique to the language. It is a fixed-length byte array of 1 to 32
 bytes, declared with *bytes* followed by the array length, for example:
 ``bytes32``, ``bytes24``, ``bytes8``, or ``bytes1``. ``byte`` is an alias for ``byte1``, so
-``byte`` is an array of 1 element. The arrays can be initialized with either a hex string or
-a text string.
+``byte`` is an array of 1 element. The arrays can be initialized with either a hex string ``hex"414243"``,
+or a text string ``"ABC"``, or a hex value ``0x414243``.
 
 .. code-block:: javascript
 
@@ -272,8 +285,8 @@ Address and Address Payable Type
 ________________________________
 
 The ``address`` type holds the address of an account. The length of an ``address`` type depends on
-the target being compiled for. On ewasm, an address is 20 bytes. Substrate has an address length
-of 32 bytes. The format of an address literal depends on what target you are building for. On ewasm,
+the target being compiled for. On ewasm, an address is 20 bytes. Solana and Substrate have an address
+length of 32 bytes. The format of an address literal depends on what target you are building for. On ewasm,
 ethereum addresses can be specified with a particular hexadecimal number.
 
 .. code-block:: javascript
@@ -339,7 +352,7 @@ _____
 
 Solidity enums types need to have a definition which lists the possible values it can hold. An enum
 has a type name, and a list of unique values. Enum types can used in public functions, but the value
-is represented as a ``uint8`` in the ABI.
+is represented as a ``uint8`` in the ABI. Enum are limited to 256 values.
 
 .. code-block:: javascript
 

+ 2 - 7
docs/running.rst

@@ -3,7 +3,8 @@ Using Solang on the command line
 
 The Solang compiler is run on the command line. The solidity source file
 names are provided as command line arguments; the output is an optimized
-wasm or bpf file which is ready for deployment on a chain, and an abi file.
+wasm or bpf file which is ready for deployment on a chain, and an metadata
+file (also known as the abi).
 
 The following targets are supported right now:
 `Solana <https://www.solana.com/>`_,
@@ -147,12 +148,6 @@ to your solidity files:
 
 	  docker run --rm -it -v /local/path:/sources hyperledgerlabs/solang -o /sources /sources/flipper.sol
 
-On podman you might need to add ``:Z`` to your volume argument if SELinux is used, like on Fedora. Also, podman allows relative paths:
-
-.. code-block:: bash
-
-	  podman container run --rm -it -v .:/sources:Z hyperledgerlabs/solang -o /sources /sources/flipper.sol
-
 On Windows, you need to specify absolute paths:
 
 .. code-block:: text