From 33641150b9fdbfe3c827276a5a59db78a3f43672 Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 12 Oct 2023 14:02:33 +0100 Subject: [PATCH] fix formatting --- .../src/app/docgen/common/properties.ts | 74 +++++++++---------- .../src/app/docgen/utils/memoized-getter.ts | 18 ++--- apps/doc-gen/src/app/docgen/utils/natspec.ts | 8 +- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/apps/doc-gen/src/app/docgen/common/properties.ts b/apps/doc-gen/src/app/docgen/common/properties.ts index 5366e8d7ef..84396f7007 100644 --- a/apps/doc-gen/src/app/docgen/common/properties.ts +++ b/apps/doc-gen/src/app/docgen/common/properties.ts @@ -36,47 +36,47 @@ export function fullName ({ item, contract }: DocItemContext): string { export function signature ({ item }: DocItemContext): string | undefined { switch (item.nodeType) { - case 'ContractDefinition': - return undefined; - - case 'FunctionDefinition': { - const { kind, name } = item; - const params = item.parameters.parameters; - const returns = item.returnParameters.parameters; - const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind; - const res = [ - `${head}(${params.map(formatVariable).join(', ')})`, - item.visibility, - ]; - if (item.stateMutability !== 'nonpayable') { - res.push(item.stateMutability); - } - if (item.virtual) { - res.push('virtual'); - } - if (returns.length > 0) { - res.push(`returns (${returns.map(formatVariable).join(', ')})`); - } - return res.join(' '); + case 'ContractDefinition': + return undefined; + + case 'FunctionDefinition': { + const { kind, name } = item; + const params = item.parameters.parameters; + const returns = item.returnParameters.parameters; + const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind; + const res = [ + `${head}(${params.map(formatVariable).join(', ')})`, + item.visibility, + ]; + if (item.stateMutability !== 'nonpayable') { + res.push(item.stateMutability); } - - case 'EventDefinition': { - const params = item.parameters.parameters; - return `event ${item.name}(${params.map(formatVariable).join(', ')})`; + if (item.virtual) { + res.push('virtual'); } - - case 'ErrorDefinition': { - const params = item.parameters.parameters; - return `error ${item.name}(${params.map(formatVariable).join(', ')})`; + if (returns.length > 0) { + res.push(`returns (${returns.map(formatVariable).join(', ')})`); } + return res.join(' '); + } - case 'ModifierDefinition': { - const params = item.parameters.parameters; - return `modifier ${item.name}(${params.map(formatVariable).join(', ')})`; - } + case 'EventDefinition': { + const params = item.parameters.parameters; + return `event ${item.name}(${params.map(formatVariable).join(', ')})`; + } - case 'VariableDeclaration': - return formatVariable(item); + case 'ErrorDefinition': { + const params = item.parameters.parameters; + return `error ${item.name}(${params.map(formatVariable).join(', ')})`; + } + + case 'ModifierDefinition': { + const params = item.parameters.parameters; + return `modifier ${item.name}(${params.map(formatVariable).join(', ')})`; + } + + case 'VariableDeclaration': + return formatVariable(item); } } @@ -177,4 +177,4 @@ export function inheritedfunctions ({ item }: DocItemContext) { contract, functions: contract.functions.filter(f => !baseFunctions.has(f.id) && (f.name !== 'constructor' || i === 0)), })) -} \ No newline at end of file +} diff --git a/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts b/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts index 1a2fef4ae5..d4814e1da2 100644 --- a/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts +++ b/apps/doc-gen/src/app/docgen/utils/memoized-getter.ts @@ -6,17 +6,17 @@ export function defineGetterMemoized