|
|
|
@ -54,26 +54,27 @@ export const template = ( |
|
|
|
|
<div id="ethdoc-viewer"> |
|
|
|
|
|
|
|
|
|
${ |
|
|
|
|
functions.length === 0 |
|
|
|
|
? "No contract to display" |
|
|
|
|
: renderHeader(name, contractDoc) |
|
|
|
|
} |
|
|
|
|
functions.length === 0 |
|
|
|
|
? "No contract to display" |
|
|
|
|
: renderHeader(name, contractDoc) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
${functions |
|
|
|
|
.map( |
|
|
|
|
(item) => ` |
|
|
|
|
<h6>${item.name} - ${item.type}</h6> |
|
|
|
|
<hr> |
|
|
|
|
${renderParameterDocumentation(item.inputs)} |
|
|
|
|
.map( |
|
|
|
|
(item) => ` |
|
|
|
|
<hr> |
|
|
|
|
<h6>${item.name} - ${item.type} </h6> |
|
|
|
|
|
|
|
|
|
${getMethodDetails(item.devdoc)} |
|
|
|
|
|
|
|
|
|
${renderParameterDocumentation(item.inputs)} |
|
|
|
|
|
|
|
|
|
<p>Returns:</p> |
|
|
|
|
|
|
|
|
|
${renderParameterDocumentation(item.outputs)} |
|
|
|
|
` |
|
|
|
|
) |
|
|
|
|
.join("\n")} |
|
|
|
|
) |
|
|
|
|
.join("\n")} |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
`;
|
|
|
|
@ -93,7 +94,7 @@ export const renderHeader = ( |
|
|
|
|
) => ` |
|
|
|
|
<h3>${name} ${ |
|
|
|
|
contractDoc.title ? `<small>: ${contractDoc.title}</small>` : "" |
|
|
|
|
}</h3> |
|
|
|
|
}</h3> |
|
|
|
|
|
|
|
|
|
${contractDoc.notice ? `<p class="lead">${contractDoc.notice}</p>` : ""} |
|
|
|
|
|
|
|
|
@ -106,8 +107,8 @@ export const renderParameterDocumentation = ( |
|
|
|
|
parameters: ParameterDocumentation[] |
|
|
|
|
) => |
|
|
|
|
`${ |
|
|
|
|
parameters.length > 0 |
|
|
|
|
? `<table class="table table-sm table-bordered table-striped">
|
|
|
|
|
parameters.length > 0 |
|
|
|
|
? `<table class="table table-sm table-bordered table-striped">
|
|
|
|
|
<thead> |
|
|
|
|
<tr> |
|
|
|
|
<th>Name</th> |
|
|
|
@ -127,16 +128,26 @@ export const renderParameterDocumentation = ( |
|
|
|
|
.join("")} |
|
|
|
|
</tbody> |
|
|
|
|
</table>` |
|
|
|
|
: "<p>No parameters</p>" |
|
|
|
|
: "<p>No parameters</p>" |
|
|
|
|
}`;
|
|
|
|
|
|
|
|
|
|
export const getMethodDetails = (devMethod?: Partial<MethodDoc>) => { |
|
|
|
|
return !devMethod |
|
|
|
|
const finalResult = !devMethod |
|
|
|
|
? "<p><strong>**Add Documentation for the method here**</strong></p>" |
|
|
|
|
: Object.keys(devMethod) |
|
|
|
|
.filter((key) => key !== "params") |
|
|
|
|
.map((key) => { |
|
|
|
|
return (devMethodDocTemplate as any)[key]((devMethod as any)[key]); |
|
|
|
|
}) |
|
|
|
|
.join("\n"); |
|
|
|
|
.filter((key) => key !== "params") |
|
|
|
|
.map((key) => { |
|
|
|
|
const funcToGetTemplate = (devMethodDocTemplate as any)[key]; |
|
|
|
|
|
|
|
|
|
if (!funcToGetTemplate) { |
|
|
|
|
return '' |
|
|
|
|
} |
|
|
|
|
const funcParameter = (devMethod as any)[key] |
|
|
|
|
const result = funcToGetTemplate(funcParameter) |
|
|
|
|
return result |
|
|
|
|
}) |
|
|
|
|
.join("\n"); |
|
|
|
|
|
|
|
|
|
console.log('finalResult', finalResult) |
|
|
|
|
return finalResult |
|
|
|
|
}; |
|
|
|
|