|
|
@ -2,7 +2,6 @@ import { |
|
|
|
FunctionDocumentation, |
|
|
|
FunctionDocumentation, |
|
|
|
TemplateDoc, |
|
|
|
TemplateDoc, |
|
|
|
MethodDoc, |
|
|
|
MethodDoc, |
|
|
|
ContractDoc, |
|
|
|
|
|
|
|
ContractDocumentation, |
|
|
|
ContractDocumentation, |
|
|
|
ParameterDocumentation, |
|
|
|
ParameterDocumentation, |
|
|
|
} from "./types"; |
|
|
|
} from "./types"; |
|
|
@ -53,14 +52,14 @@ export const template = ( |
|
|
|
<div id="ethdoc-viewer"> |
|
|
|
<div id="ethdoc-viewer"> |
|
|
|
|
|
|
|
|
|
|
|
${ |
|
|
|
${ |
|
|
|
functions.length === 0 |
|
|
|
functions.length === 0 |
|
|
|
? "No contract to display" |
|
|
|
? "No contract to display" |
|
|
|
: renderHeader(name, contractDoc) |
|
|
|
: renderHeader(name, contractDoc) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
${functions |
|
|
|
${functions |
|
|
|
.map( |
|
|
|
.map( |
|
|
|
(item) => ` |
|
|
|
(item) => ` |
|
|
|
<h6>${item.name} - ${item.type}</h6> |
|
|
|
<h6>${item.name} - ${item.type}</h6> |
|
|
|
<hr> |
|
|
|
<hr> |
|
|
|
${renderParameterDocumentation(item.inputs)} |
|
|
|
${renderParameterDocumentation(item.inputs)} |
|
|
@ -72,8 +71,8 @@ export const template = ( |
|
|
|
${renderParameterDocumentation(item.outputs)} |
|
|
|
${renderParameterDocumentation(item.outputs)} |
|
|
|
|
|
|
|
|
|
|
|
` |
|
|
|
` |
|
|
|
) |
|
|
|
) |
|
|
|
.join("\n")} |
|
|
|
.join("\n")} |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
`;
|
|
|
|
`;
|
|
|
@ -104,7 +103,7 @@ export const renderHeader = ( |
|
|
|
) => ` |
|
|
|
) => ` |
|
|
|
<h3>${name} ${ |
|
|
|
<h3>${name} ${ |
|
|
|
contractDoc.title ? `<small>: ${contractDoc.title}</small>` : "" |
|
|
|
contractDoc.title ? `<small>: ${contractDoc.title}</small>` : "" |
|
|
|
}</h3> |
|
|
|
}</h3> |
|
|
|
|
|
|
|
|
|
|
|
${contractDoc.notice ? `<p class="lead">${contractDoc.notice}</p>` : ""} |
|
|
|
${contractDoc.notice ? `<p class="lead">${contractDoc.notice}</p>` : ""} |
|
|
|
|
|
|
|
|
|
|
@ -117,8 +116,8 @@ export const renderParameterDocumentation = ( |
|
|
|
parameters: ParameterDocumentation[] |
|
|
|
parameters: ParameterDocumentation[] |
|
|
|
) => ` |
|
|
|
) => ` |
|
|
|
${ |
|
|
|
${ |
|
|
|
parameters.length > 0 |
|
|
|
parameters.length > 0 |
|
|
|
? ` |
|
|
|
? ` |
|
|
|
<table class="table table-sm table-bordered table-striped"> |
|
|
|
<table class="table table-sm table-bordered table-striped"> |
|
|
|
<thead> |
|
|
|
<thead> |
|
|
|
<tr> |
|
|
|
<tr> |
|
|
@ -129,25 +128,25 @@ export const renderParameterDocumentation = ( |
|
|
|
</thead> |
|
|
|
</thead> |
|
|
|
<tbody> |
|
|
|
<tbody> |
|
|
|
${parameters.map( |
|
|
|
${parameters.map( |
|
|
|
(output) => `<tr>
|
|
|
|
(output) => `<tr>
|
|
|
|
<td>${output.name}</td> |
|
|
|
<td>${output.name}</td> |
|
|
|
<td>${output.type}</td> |
|
|
|
<td>${output.type}</td> |
|
|
|
<td>${output.description}</td> |
|
|
|
<td>${output.description}</td> |
|
|
|
</tr>` |
|
|
|
</tr>` |
|
|
|
)} |
|
|
|
)} |
|
|
|
</tbody> |
|
|
|
</tbody> |
|
|
|
</table>` |
|
|
|
</table>` |
|
|
|
: "<p>No parameters</p>" |
|
|
|
: "<p>No parameters</p>" |
|
|
|
} |
|
|
|
} |
|
|
|
`;
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
export const getMethodDetails = (devMethod?: Partial<MethodDoc>) => { |
|
|
|
export const getMethodDetails = (devMethod?: Partial<MethodDoc>) => { |
|
|
|
return !devMethod |
|
|
|
return !devMethod |
|
|
|
? "<p><strong>**Add Documentation for the method here**</strong></p>" |
|
|
|
? "<p><strong>**Add Documentation for the method here**</strong></p>" |
|
|
|
: Object.keys(devMethod) |
|
|
|
: Object.keys(devMethod) |
|
|
|
.filter((key) => key !== "params") |
|
|
|
.filter((key) => key !== "params") |
|
|
|
.map((key) => { |
|
|
|
.map((key) => { |
|
|
|
(devMethodDocTemplate as any)[key]((devMethod as any)[key]); |
|
|
|
return (devMethodDocTemplate as any)[key]((devMethod as any)[key]); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.join("\n"); |
|
|
|
.join("\n"); |
|
|
|
}; |
|
|
|
}; |
|
|
|