|
|
@ -36,47 +36,47 @@ export function fullName ({ item, contract }: DocItemContext): string { |
|
|
|
|
|
|
|
|
|
|
|
export function signature ({ item }: DocItemContext): string | undefined { |
|
|
|
export function signature ({ item }: DocItemContext): string | undefined { |
|
|
|
switch (item.nodeType) { |
|
|
|
switch (item.nodeType) { |
|
|
|
case 'ContractDefinition': |
|
|
|
case 'ContractDefinition': |
|
|
|
return undefined; |
|
|
|
return undefined; |
|
|
|
|
|
|
|
|
|
|
|
case 'FunctionDefinition': { |
|
|
|
case 'FunctionDefinition': { |
|
|
|
const { kind, name } = item; |
|
|
|
const { kind, name } = item; |
|
|
|
const params = item.parameters.parameters; |
|
|
|
const params = item.parameters.parameters; |
|
|
|
const returns = item.returnParameters.parameters; |
|
|
|
const returns = item.returnParameters.parameters; |
|
|
|
const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind; |
|
|
|
const head = (kind === 'function' || kind === 'freeFunction') ? [kind, name].join(' ') : kind; |
|
|
|
const res = [ |
|
|
|
const res = [ |
|
|
|
`${head}(${params.map(formatVariable).join(', ')})`, |
|
|
|
`${head}(${params.map(formatVariable).join(', ')})`, |
|
|
|
item.visibility, |
|
|
|
item.visibility, |
|
|
|
]; |
|
|
|
]; |
|
|
|
if (item.stateMutability !== 'nonpayable') { |
|
|
|
if (item.stateMutability !== 'nonpayable') { |
|
|
|
res.push(item.stateMutability); |
|
|
|
res.push(item.stateMutability); |
|
|
|
} |
|
|
|
|
|
|
|
if (item.virtual) { |
|
|
|
|
|
|
|
res.push('virtual'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (returns.length > 0) { |
|
|
|
|
|
|
|
res.push(`returns (${returns.map(formatVariable).join(', ')})`); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return res.join(' '); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (item.virtual) { |
|
|
|
case 'EventDefinition': { |
|
|
|
res.push('virtual'); |
|
|
|
const params = item.parameters.parameters; |
|
|
|
|
|
|
|
return `event ${item.name}(${params.map(formatVariable).join(', ')})`; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (returns.length > 0) { |
|
|
|
case 'ErrorDefinition': { |
|
|
|
res.push(`returns (${returns.map(formatVariable).join(', ')})`); |
|
|
|
const params = item.parameters.parameters; |
|
|
|
|
|
|
|
return `error ${item.name}(${params.map(formatVariable).join(', ')})`; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return res.join(' '); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 'ModifierDefinition': { |
|
|
|
case 'EventDefinition': { |
|
|
|
const params = item.parameters.parameters; |
|
|
|
const params = item.parameters.parameters; |
|
|
|
return `modifier ${item.name}(${params.map(formatVariable).join(', ')})`; |
|
|
|
return `event ${item.name}(${params.map(formatVariable).join(', ')})`; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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': |
|
|
|
case 'VariableDeclaration': |
|
|
|
return formatVariable(item); |
|
|
|
return formatVariable(item); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|