Ensure constant getters show in docs (#4649)
(cherry picked from commit 39400b78ba)
This commit is contained in:
committed by
Francisco Giordano
parent
21ef8130c8
commit
e49fcbeb56
2
docs/templates/contract.hbs
vendored
2
docs/templates/contract.hbs
vendored
@ -86,7 +86,7 @@ import "@openzeppelin/{{__item_context.file.absolutePath}}";
|
||||
{{#each functions}}
|
||||
[.contract-item]
|
||||
[[{{anchor}}]]
|
||||
==== `[.contract-item-name]#++{{name}}++#++({{typed-params params}}){{#if returns}} → {{typed-params returns}}{{/if}}++` [.item-kind]#{{visibility}}#
|
||||
==== `[.contract-item-name]#++{{name}}++#++({{typed-params params}}){{#if returns2}} → {{typed-params returns2}}{{/if}}++` [.item-kind]#{{visibility}}#
|
||||
|
||||
{{{natspec.dev}}}
|
||||
|
||||
|
||||
2
docs/templates/helpers.js
vendored
2
docs/templates/helpers.js
vendored
@ -6,7 +6,7 @@ module.exports['readme-path'] = opts => {
|
||||
return 'contracts/' + opts.data.root.id.replace(/\.adoc$/, '') + '/README.adoc';
|
||||
};
|
||||
|
||||
module.exports.names = params => params.map(p => p.name).join(', ');
|
||||
module.exports.names = params => params?.map(p => p.name).join(', ');
|
||||
|
||||
module.exports['typed-params'] = params => {
|
||||
return params?.map(p => `${p.type}${p.indexed ? ' indexed' : ''}${p.name ? ' ' + p.name : ''}`).join(', ');
|
||||
|
||||
17
docs/templates/properties.js
vendored
17
docs/templates/properties.js
vendored
@ -1,4 +1,4 @@
|
||||
const { isNodeType } = require('solidity-ast/utils');
|
||||
const { isNodeType, findAll } = require('solidity-ast/utils');
|
||||
const { slug } = require('./helpers');
|
||||
|
||||
module.exports.anchor = function anchor({ item, contract }) {
|
||||
@ -39,6 +39,21 @@ module.exports['has-errors'] = function ({ item }) {
|
||||
return item.inheritance.some(c => c.errors.length > 0);
|
||||
};
|
||||
|
||||
module.exports.functions = function ({ item }) {
|
||||
return [
|
||||
...[...findAll('FunctionDefinition', item)].filter(f => f.visibility !== 'private'),
|
||||
...[...findAll('VariableDeclaration', item)].filter(f => f.visibility === 'public'),
|
||||
];
|
||||
};
|
||||
|
||||
module.exports.returns2 = function ({ item }) {
|
||||
if (isNodeType('VariableDeclaration', item)) {
|
||||
return [{ type: item.typeDescriptions.typeString }];
|
||||
} else {
|
||||
return item.returns;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports['inherited-functions'] = function ({ item }) {
|
||||
const { inheritance } = item;
|
||||
const baseFunctions = new Set(inheritance.flatMap(c => c.functions.flatMap(f => f.baseFunctions ?? [])));
|
||||
|
||||
Reference in New Issue
Block a user