diff --git a/src/index.ts b/src/index.ts index 09b9c7b..bc492ab 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,14 +71,14 @@ async function generateDocumentation(hre: HardhatRuntimeEnvironment): Promise { // Check if there is not the same number of Natspec @return tags compared // to the number of return params for the function in the AST node. - if (returnParam[index] === undefined) return; + if (returnDoc[index] === undefined) return; const returnVariableName = returnParam.name === '' ? `_${index}` : returnParam.name; - const returnParamType = returnParam.typeName.name; + const returnParamType = returnParam.typeDescriptions.typeString; doc[docEntry][functionName].outputs[returnVariableName] = { type: returnParamType, @@ -393,22 +393,28 @@ async function generateDocumentation(hre: HardhatRuntimeEnvironment): Promise param.typeName.name) + .map((param: any) => param.typeDescriptions.typeString) .join(',')})`; let internalFunctionCode = `function ${functionName}(${params - .map((param: any) => `${param.typeName.name} ${param.name}`) - .join(',')}) internal`; + .map((param: any) => `${param.typeDescriptions.typeString} ${param.name}`) + .join(', ')}) internal`; internalFunctionCode += ` ${stateMutability}`; if (returnParams.length > 0) { internalFunctionCode += ` returns (${returnParams - .map((returnParam: any) => `${returnParam.typeName.name} ${returnParam.name}`) - .join(',')})`; - } + .map((returnParam: any) => { + let returnStatement = `${returnParam.typeDescriptions.typeString}`; + + if (returnParam.name !== '') { + returnStatement += ` ${returnParam.name}`; + } - internalFunctionCode += ';'; + return returnStatement; + }) + .join(', ')})`; + } if (!doc.internalMethods) { doc.internalMethods = {};