-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation of global variables #43
Comments
Thanks for the suggestion! Agree that we need to support this. Feel free to submit a pull request with these changes. |
barakman
added a commit
to barakman/solidity-docgen
that referenced
this issue
Sep 1, 2019
Following [this feature-request](OpenZeppelin#43), extending the `solidity-docgen` package to support the documentation of global variables, which are implicitly added by the compiler as getter functions in the contract. This should allow users to get the natspec-documentation of their global variables added into the `solidity-docgen` output by extending the input template (hbs) file. For example: ``` {{#if ownVariables}} # Variables: {{#ownVariables}} - [`{{type}} {{name}}`](#{{anchor}}) {{/ownVariables}} {{/if}} {{#ownVariables}} # Variable `{{type}} {{name}}` {#{{anchor~}} } {{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}No description{{/if}} {{/ownVariables}} ``` Note that this PR is incomplete, since the `devdoc` of a global variable is always `undefined`. For this reason, I also had to override function `SolidityContractItem.natspec()` in class `SolidityVariable` with a slightly different implementation (since `this.astNode.documentation === undefined`).
frangio
pushed a commit
that referenced
this issue
Nov 6, 2019
* Support the documentation of global variables Following [this feature-request](#43), extending the `solidity-docgen` package to support the documentation of global variables, which are implicitly added by the compiler as getter functions in the contract. This should allow users to get the natspec-documentation of their global variables added into the `solidity-docgen` output by extending the input template (hbs) file. For example: ``` {{#if ownVariables}} # Variables: {{#ownVariables}} - [`{{type}} {{name}}`](#{{anchor}}) {{/ownVariables}} {{/if}} {{#ownVariables}} # Variable `{{type}} {{name}}` {#{{anchor~}} } {{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}No description{{/if}} {{/ownVariables}} ``` Note that this PR is incomplete, since the `devdoc` of a global variable is always `undefined`. For this reason, I also had to override function `SolidityContractItem.natspec()` in class `SolidityVariable` with a slightly different implementation (since `this.astNode.documentation === undefined`). * Fix function `SolidityVariable.type()` * Throw error in function SolidityVariable.natspec Since NatSpec currently does NOT apply to public state variables (see ethereum/solidity#3418). * Add `this.variables` to the array returned by `linkable` As requested at #44 (comment). * Update src/solidity.ts Co-Authored-By: Francisco Giordano <frangio.1@gmail.com> * Add the definition of `interface VariableDeclaration` As requested at #44 (comment). * Fix the `VariableDeclaration` interface Remove the n/a `documentation` field. * Fix class `SolidityVariable` Let this class implement `Linkable` instead of extending `SolidityContractItem`. * add missing semicolons and commas * rename typeName to type * add necessary members in variable ast node interface * remove unused constructor argument * finish implementation of state variable documentation * add tests for state variables * add warning for state variable natspec
Fixed in #44. |
douglasletz
added a commit
to douglasletz/pickle-solidity-pro
that referenced
this issue
Sep 15, 2021
* Support the documentation of global variables Following [this feature-request](OpenZeppelin/solidity-docgen#43), extending the `solidity-docgen` package to support the documentation of global variables, which are implicitly added by the compiler as getter functions in the contract. This should allow users to get the natspec-documentation of their global variables added into the `solidity-docgen` output by extending the input template (hbs) file. For example: ``` {{#if ownVariables}} # Variables: {{#ownVariables}} - [`{{type}} {{name}}`](#{{anchor}}) {{/ownVariables}} {{/if}} {{#ownVariables}} # Variable `{{type}} {{name}}` {#{{anchor~}} } {{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}No description{{/if}} {{/ownVariables}} ``` Note that this PR is incomplete, since the `devdoc` of a global variable is always `undefined`. For this reason, I also had to override function `SolidityContractItem.natspec()` in class `SolidityVariable` with a slightly different implementation (since `this.astNode.documentation === undefined`). * Fix function `SolidityVariable.type()` * Throw error in function SolidityVariable.natspec Since NatSpec currently does NOT apply to public state variables (see ethereum/solidity#3418). * Add `this.variables` to the array returned by `linkable` As requested at OpenZeppelin/solidity-docgen#44 (comment). * Update src/solidity.ts Co-Authored-By: Francisco Giordano <frangio.1@gmail.com> * Add the definition of `interface VariableDeclaration` As requested at OpenZeppelin/solidity-docgen#44 (comment). * Fix the `VariableDeclaration` interface Remove the n/a `documentation` field. * Fix class `SolidityVariable` Let this class implement `Linkable` instead of extending `SolidityContractItem`. * add missing semicolons and commas * rename typeName to type * add necessary members in variable ast node interface * remove unused constructor argument * finish implementation of state variable documentation * add tests for state variables * add warning for state variable natspec
Ishanamgai
added a commit
to Ishanamgai/F-Solidity
that referenced
this issue
Feb 4, 2022
* Support the documentation of global variables Following [this feature-request](OpenZeppelin/solidity-docgen#43), extending the `solidity-docgen` package to support the documentation of global variables, which are implicitly added by the compiler as getter functions in the contract. This should allow users to get the natspec-documentation of their global variables added into the `solidity-docgen` output by extending the input template (hbs) file. For example: ``` {{#if ownVariables}} # Variables: {{#ownVariables}} - [`{{type}} {{name}}`](#{{anchor}}) {{/ownVariables}} {{/if}} {{#ownVariables}} # Variable `{{type}} {{name}}` {#{{anchor~}} } {{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}No description{{/if}} {{/ownVariables}} ``` Note that this PR is incomplete, since the `devdoc` of a global variable is always `undefined`. For this reason, I also had to override function `SolidityContractItem.natspec()` in class `SolidityVariable` with a slightly different implementation (since `this.astNode.documentation === undefined`). * Fix function `SolidityVariable.type()` * Throw error in function SolidityVariable.natspec Since NatSpec currently does NOT apply to public state variables (see ethereum/solidity#3418). * Add `this.variables` to the array returned by `linkable` As requested at OpenZeppelin/solidity-docgen#44 (comment). * Update src/solidity.ts Co-Authored-By: Francisco Giordano <frangio.1@gmail.com> * Add the definition of `interface VariableDeclaration` As requested at OpenZeppelin/solidity-docgen#44 (comment). * Fix the `VariableDeclaration` interface Remove the n/a `documentation` field. * Fix class `SolidityVariable` Let this class implement `Linkable` instead of extending `SolidityContractItem`. * add missing semicolons and commas * rename typeName to type * add necessary members in variable ast node interface * remove unused constructor argument * finish implementation of state variable documentation * add tests for state variables * add warning for state variable natspec
topsuperdev
added a commit
to topsuperdev/Solidity-Pro
that referenced
this issue
Jun 14, 2022
* Support the documentation of global variables Following [this feature-request](OpenZeppelin/solidity-docgen#43), extending the `solidity-docgen` package to support the documentation of global variables, which are implicitly added by the compiler as getter functions in the contract. This should allow users to get the natspec-documentation of their global variables added into the `solidity-docgen` output by extending the input template (hbs) file. For example: ``` {{#if ownVariables}} # Variables: {{#ownVariables}} - [`{{type}} {{name}}`](#{{anchor}}) {{/ownVariables}} {{/if}} {{#ownVariables}} # Variable `{{type}} {{name}}` {#{{anchor~}} } {{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}No description{{/if}} {{/ownVariables}} ``` Note that this PR is incomplete, since the `devdoc` of a global variable is always `undefined`. For this reason, I also had to override function `SolidityContractItem.natspec()` in class `SolidityVariable` with a slightly different implementation (since `this.astNode.documentation === undefined`). * Fix function `SolidityVariable.type()` * Throw error in function SolidityVariable.natspec Since NatSpec currently does NOT apply to public state variables (see ethereum/solidity#3418). * Add `this.variables` to the array returned by `linkable` As requested at OpenZeppelin/solidity-docgen#44 (comment). * Update src/solidity.ts Co-Authored-By: Francisco Giordano <frangio.1@gmail.com> * Add the definition of `interface VariableDeclaration` As requested at OpenZeppelin/solidity-docgen#44 (comment). * Fix the `VariableDeclaration` interface Remove the n/a `documentation` field. * Fix class `SolidityVariable` Let this class implement `Linkable` instead of extending `SolidityContractItem`. * add missing semicolons and commas * rename typeName to type * add necessary members in variable ast node interface * remove unused constructor argument * finish implementation of state variable documentation * add tests for state variables * add warning for state variable natspec
yon3030
added a commit
to yon3030/yantoColor
that referenced
this issue
Oct 24, 2024
* Support the documentation of global variables Following [this feature-request](OpenZeppelin/solidity-docgen#43), extending the `solidity-docgen` package to support the documentation of global variables, which are implicitly added by the compiler as getter functions in the contract. This should allow users to get the natspec-documentation of their global variables added into the `solidity-docgen` output by extending the input template (hbs) file. For example: ``` {{#if ownVariables}} # Variables: {{#ownVariables}} - [`{{type}} {{name}}`](#{{anchor}}) {{/ownVariables}} {{/if}} {{#ownVariables}} # Variable `{{type}} {{name}}` {#{{anchor~}} } {{#if natspec.devdoc}}{{natspec.devdoc}}{{else}}No description{{/if}} {{/ownVariables}} ``` Note that this PR is incomplete, since the `devdoc` of a global variable is always `undefined`. For this reason, I also had to override function `SolidityContractItem.natspec()` in class `SolidityVariable` with a slightly different implementation (since `this.astNode.documentation === undefined`). * Fix function `SolidityVariable.type()` * Throw error in function SolidityVariable.natspec Since NatSpec currently does NOT apply to public state variables (see ethereum/solidity#3418). * Add `this.variables` to the array returned by `linkable` As requested at OpenZeppelin/solidity-docgen#44 (comment). * Update src/solidity.ts Co-Authored-By: Francisco Giordano <frangio.1@gmail.com> * Add the definition of `interface VariableDeclaration` As requested at OpenZeppelin/solidity-docgen#44 (comment). * Fix the `VariableDeclaration` interface Remove the n/a `documentation` field. * Fix class `SolidityVariable` Let this class implement `Linkable` instead of extending `SolidityContractItem`. * add missing semicolons and commas * rename typeName to type * add necessary members in variable ast node interface * remove unused constructor argument * finish implementation of state variable documentation * add tests for state variables * add warning for state variable natspec
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As you know, the compiler implicitly creates a getter function for each global variable which is declared
public
.Ideally, I'd like each one of these getter functions added to solidity-docgen's output (provided that I document them of course).
I assume that it might be a little difficult to actually display them as functions, because the solidity-parser (AST builder) adds them to the tree as variables.
So I would settle for having them displayed as variables.
For this purpose, I believe that you'd need to handle the
VariableDeclaration
node-type.This means that in file
solidity.js
, you'd need to add:SolidityContract
:SolidityContract
:SolidityContract
:Thanks
The text was updated successfully, but these errors were encountered: