Merge pull request #6874 from ethereum/docs-style-fix-style

[DOCS] Bring code examples for Style Guide inline with style guide
This commit is contained in:
Chris Chinchilla 2019-06-06 11:23:15 +02:00 committed by GitHub
commit fc35c139ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -757,20 +757,26 @@ No::
pragma solidity >=0.4.0 <0.7.0;
// Base contracts just to make this compile
contract B {
constructor(uint) public {
}
}
contract C {
constructor(uint, uint) public {
}
}
contract D {
constructor(uint) public {
}
}
contract A is B, C, D {
uint x;
@ -778,12 +784,12 @@ No::
B(param1)
C(param2, param3)
D(param4)
public
{
public {
x = param5;
}
}
contract X is B, C, D {
uint x;
@ -792,10 +798,11 @@ No::
C(param2, param3)
D(param4)
public {
x = param5;
}
x = param5;
}
}
When declaring short functions with a single statement, it is permissible to do it on a single line.
Permissible::
@ -973,27 +980,32 @@ Yes::
pragma solidity >=0.4.0 <0.7.0;
// Owned.sol
contract Owned {
address public owner;
address public owner;
constructor() public {
owner = msg.sender;
}
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
}
// Congress.sol
and in ``Congress.sol``::
pragma solidity >=0.4.0 <0.7.0;
import "./Owned.sol";
contract Congress is Owned, TokenRecipient {
//...
}
@ -1002,32 +1014,34 @@ No::
pragma solidity >=0.4.0 <0.7.0;
// owned.sol
contract owned {
address public owner;
address public owner;
constructor() public {
owner = msg.sender;
}
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
}
// Congress.sol
and in ``Congress.sol``::
import "./owned.sol";
contract Congress is owned, tokenRecipient {
//...
}
Struct Names
==========================
@ -1104,6 +1118,7 @@ added looks like the one below::
pragma solidity >=0.4.0 <0.7.0;
/// @author The Solidity Team
/// @title A simple storage example
contract SimpleStorage {