OpenZeppelin / solidity-docgen

Documentation generator for Solidity projects
MIT License
452 stars 118 forks source link

Create option to exclude (or not) private and/or internal functions #457

Closed gruvin closed 4 months ago

gruvin commented 4 months ago

Functions with visibility 'private' are currently hard-coded to be excluded. I note that others also would like this not to be the case at times.

I wish to also exclude 'internal' functions from public facing documentation.

I use 'internal' over 'private' in cases where functions or state variables are not 'public' but I need to audit their values or effects by sub-classing (extending) the main contract with utility test functions. Derived contract (those extended from others) cannot access private variables or override private functions but can do so with 'internal' variants. In either case, I have no desire for public facing documentation to include private or internal functions.

Thanks! :-)

gruvin commented 4 months ago

In fact, why not simply reverse the logic to only include 'public'?

frangio commented 4 months ago

This is configurable.

Create a docs-templates directory and configure the plugin to use it in hardhat.config.js:

docgen: {
  templates: 'docs-templates',
}

Add docs-templates/contract.hbs:

{{>common}}

{{#each items}}
{{#unless (eq visibility "internal")}}
{{#hsection}}
{{>item}}
{{/hsection}}
{{/unless}}

{{/each}}
gruvin commented 4 months ago

Oh! Thanks for that.

I tried to find such a think in the source code, since there doesn't seem to be any documentation yet but I'm too n00bish. ;-)