From 7e4896740daef2c777f5cb434edb0e95e82e3430 Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Thu, 16 May 2019 12:27:30 +0200 Subject: [PATCH] Clarify that public applies to state variables --- docs/miscellaneous.rst | 2 +- docs/natspec-format.rst | 17 ++++++++++------- docs/types/mapping-types.rst | 2 +- docs/types/value-types.rst | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index 69a08bdf9..137513b83 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -269,7 +269,7 @@ Tips and Tricks * Use ``delete`` on arrays to delete all its elements. * Use shorter types for struct elements and sort them such that short types are grouped together. This can lower the gas costs as multiple ``SSTORE`` operations might be combined into a single (``SSTORE`` costs 5000 or 20000 gas, so this is what you want to optimise). Use the gas price estimator (with optimiser enabled) to check! -* Make your state variables public - the compiler will create :ref:`getters ` for you automatically. +* Make your state variables public - the compiler creates :ref:`getters ` for you automatically. * If you end up checking conditions on input or state a lot at the beginning of your functions, try using :ref:`modifiers`. * Initialize storage structs with a single assignment: ``x = MyStruct({a: 1, b: 2});`` diff --git a/docs/natspec-format.rst b/docs/natspec-format.rst index 297d9954c..2ba6d2188 100644 --- a/docs/natspec-format.rst +++ b/docs/natspec-format.rst @@ -36,12 +36,16 @@ Documentation is inserted above each ``class``, ``interface`` and documentation `__. The following example shows a contract and a function using all available tags. -Note: NatSpec currently does NOT apply to public state variables (see -`solidity#3418 `__), -even if they are declared public and therefore do affect the ABI. Note: -The Solidity compiler only interprets tags if they are external or -public. You are welcome to use similar comments for your internal and -private functions, but those will not be parsed. + +.. note:: + + NatSpec currently does NOT apply to public state variables (see + `solidity#3418 `__), + even if they are declared public and therefore do affect the ABI. + + The Solidity compiler only interprets tags if they are external or + public. You are welcome to use similar comments for your internal and + private functions, but those will not be parsed. .. code:: solidity @@ -196,4 +200,3 @@ file should also be produced and should look like this: }, "title" : "A simulator for trees" } - diff --git a/docs/types/mapping-types.rst b/docs/types/mapping-types.rst index 2414687c5..afee61202 100644 --- a/docs/types/mapping-types.rst +++ b/docs/types/mapping-types.rst @@ -25,7 +25,7 @@ in functions, or as parameters for library functions. They cannot be used as parameters or return parameters of contract functions that are publicly visible. -You can mark variables of mapping type as ``public`` and Solidity creates a +You can mark state variables of mapping type as ``public`` and Solidity creates a :ref:`getter ` for you. The ``_KeyType`` becomes a parameter for the getter. If ``_ValueType`` is a value type or a struct, the getter returns ``_ValueType``. diff --git a/docs/types/value-types.rst b/docs/types/value-types.rst index 507338f12..b8d67399a 100644 --- a/docs/types/value-types.rst +++ b/docs/types/value-types.rst @@ -333,7 +333,7 @@ type and this type is also used in the :ref:`ABI`. Contracts do not support any operators. The members of contract types are the external functions of the contract -including public state variables. +including any state variables marked as ``public``. For a contract ``C`` you can use ``type(C)`` to access :ref:`type information` about the contract.