Add custom errors to docs (#4480)

This commit is contained in:
Ernesto García
2023-07-27 17:18:45 -06:00
committed by GitHub
parent 9445f96223
commit 02ea01765a
5 changed files with 47 additions and 11 deletions

View File

@ -57,6 +57,23 @@ import "@openzeppelin/{{__item_context.file.absolutePath}}";
--
{{/if}}
{{#if has-errors}}
[.contract-index]
.Errors
--
{{#each inheritance}}
{{#unless @first}}
[.contract-subindex-inherited]
.{{name}}
{{/unless}}
{{#each errors}}
* {xref-{{anchor~}} }[`++{{name}}({{names params}})++`]
{{/each}}
{{/each}}
--
{{/if}}
{{#each modifiers}}
[.contract-item]
[[{{anchor}}]]
@ -83,3 +100,12 @@ import "@openzeppelin/{{__item_context.file.absolutePath}}";
{{{natspec.dev}}}
{{/each}}
{{#each errors}}
[.contract-item]
[[{{anchor}}]]
==== `[.contract-item-name]#++{{name}}++#++({{typed-params params}})++` [.item-kind]#error#
{{{natspec.dev}}}
{{/each}}

View File

@ -35,6 +35,10 @@ module.exports['has-events'] = function ({ item }) {
return item.inheritance.some(c => c.events.length > 0);
};
module.exports['has-errors'] = function ({ item }) {
return item.inheritance.some(c => c.errors.length > 0);
};
module.exports['inherited-functions'] = function ({ item }) {
const { inheritance } = item;
const baseFunctions = new Set(inheritance.flatMap(c => c.functions.flatMap(f => f.baseFunctions ?? [])));