aboutsummaryrefslogtreecommitdiffstats
path: root/docs/style-guide.rst
diff options
context:
space:
mode:
authorLuke Schoen <ltfschoen@users.noreply.github.com>2018-02-13 14:52:24 +0800
committerchriseth <chris@ethereum.org>2018-08-07 00:23:58 +0800
commit835c05cb3a61202d1e2b87fc6671850039cc0b8e (patch)
treeefecd8db9218d2533f3edfd87d0b9f78a3a519b7 /docs/style-guide.rst
parent7c9bfb62f9047f6ed18b095ba756ffe2511f0ec8 (diff)
downloaddexon-solidity-835c05cb3a61202d1e2b87fc6671850039cc0b8e.tar
dexon-solidity-835c05cb3a61202d1e2b87fc6671850039cc0b8e.tar.gz
dexon-solidity-835c05cb3a61202d1e2b87fc6671850039cc0b8e.tar.bz2
dexon-solidity-835c05cb3a61202d1e2b87fc6671850039cc0b8e.tar.lz
dexon-solidity-835c05cb3a61202d1e2b87fc6671850039cc0b8e.tar.xz
dexon-solidity-835c05cb3a61202d1e2b87fc6671850039cc0b8e.tar.zst
dexon-solidity-835c05cb3a61202d1e2b87fc6671850039cc0b8e.zip
Update style guide with regards to CapWords requirement for contract and file naming.
Diffstat (limited to 'docs/style-guide.rst')
-rw-r--r--docs/style-guide.rst68
1 files changed, 63 insertions, 5 deletions
diff --git a/docs/style-guide.rst b/docs/style-guide.rst
index 19e3aae5..53e126b4 100644
--- a/docs/style-guide.rst
+++ b/docs/style-guide.rst
@@ -229,7 +229,7 @@ Import statements should always be placed at the top of the file.
Yes::
- import "owned";
+ import "./Owned.sol";
contract A {
@@ -237,7 +237,7 @@ Yes::
}
- contract B is owned {
+ contract B is Owned {
...
}
@@ -248,10 +248,10 @@ No::
}
- import "owned";
+ import "./Owned.sol";
- contract B is owned {
+ contract B is Owned {
...
}
@@ -867,7 +867,65 @@ indistinguishable from the numerals one and zero.
Contract and Library Names
==========================
-Contracts and libraries should be named using the CapWords style. Examples: ``SimpleToken``, ``SmartBank``, ``CertificateHashRepository``, ``Player``.
+* Contracts and libraries should be named using the CapWords style. Examples: ``SimpleToken``, ``SmartBank``, ``CertificateHashRepository``, ``Player``, ``Congress``, ``Owned``.
+* Contract and library names should also match their filenames.
+* If a contract file includes multiple contracts and/or libraries, then the filename should match the *core contract*. This is not recommended however if it can be avoided.
+
+As shown in the example below, if the contract name is `Congress` and the library name is `Owned`, then their associated filenames should be `Congress.sol` and `Owned.sol`.
+
+Yes::
+
+ // Owned.sol
+ contract Owned {
+ address public owner;
+
+ constructor() public {
+ owner = msg.sender;
+ }
+
+ modifier onlyOwner {
+ require(msg.sender == owner);
+ _;
+ }
+
+ function transferOwnership(address newOwner) public onlyOwner {
+ owner = newOwner;
+ }
+ }
+
+ // Congress.sol
+ import "./Owned.sol";
+
+ contract Congress is Owned, TokenRecipient {
+ ...
+ }
+
+No::
+
+ // owned.sol
+ contract owned {
+ address public owner;
+
+ constructor() public {
+ owner = msg.sender;
+ }
+
+ modifier onlyOwner {
+ require(msg.sender == owner);
+ _;
+ }
+
+ function transferOwnership(address newOwner) public onlyOwner {
+ owner = newOwner;
+ }
+ }
+
+ // Congress.sol
+ import "./owned.sol";
+
+ contract Congress is owned, tokenRecipient {
+ ...
+ }
Struct Names