fix build issues

pull/5370/head
Solid Studio 4 years ago committed by Aniket
parent 48bc8e24a0
commit c71a92c4d6
  1. 3
      src/AppContext.tsx
  2. 2
      src/index.tsx
  3. 41
      src/utils/template.ts
  4. 9
      src/utils/utils.ts
  5. 2
      src/views/ErrorView.tsx
  6. 2
      src/views/HomeView.tsx

@ -3,8 +3,7 @@ import {
PluginApi, PluginApi,
IRemixApi, IRemixApi,
Api, Api,
PluginClient, PluginClient
CompilationResult,
} from "@remixproject/plugin"; } from "@remixproject/plugin";
import { ContractName, Documentation, PublishedSite } from "./types"; import { ContractName, Documentation, PublishedSite } from "./types";

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import App from "./App"; import App from "./App";
import { Routes } from "./routes"; // import { Routes } from "./routes";
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>

@ -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");
}; };

@ -2,16 +2,11 @@ import {
CompilationResult, CompilationResult,
CompiledContract, CompiledContract,
FunctionDescription, FunctionDescription,
ABIDescription,
DevMethodDoc,
UserMethodDoc,
ABIParameter, ABIParameter,
DeveloperDocumentation, ABIDescription
UserDocumentation,
} from "@remixproject/plugin"; } from "@remixproject/plugin";
import { import {
EthDocumentation,
FileName, FileName,
Documentation, Documentation,
ContractName, ContractName,
@ -73,7 +68,7 @@ export const getContractDoc = (name: string, contract: CompiledContract) => {
export const getContractDocumentation = (contract: CompiledContract) => { export const getContractDocumentation = (contract: CompiledContract) => {
const methods: MethodsDocumentation = {}; const methods: MethodsDocumentation = {};
Object.keys(contract.userdoc.methods).map((item) => { Object.keys(contract.userdoc.methods).forEach((item) => {
if (contract.devdoc.methods[item]) { if (contract.devdoc.methods[item]) {
const finalResult = { const finalResult = {
...contract.userdoc.methods[item], ...contract.userdoc.methods[item],

@ -19,7 +19,7 @@ export const ErrorView: React.FC = () => {
<h5>Sorry, something unexpected happened. </h5> <h5>Sorry, something unexpected happened. </h5>
<h5> <h5>
Please raise an issue:{" "} Please raise an issue:{" "}
<a style={{ color: "red" }} href=""> <a style={{ color: "red" }} href="https://github.com/Machinalabs/remix-ethdoc-plugin/issues">
Here Here
</a> </a>
</h5> </h5>

@ -27,7 +27,7 @@ export const HomeView: React.FC = () => {
if (isPublishing) { if (isPublishing) {
publishDocumentation(); publishDocumentation();
} }
}, [isPublishing]); }, [isPublishing, htmlDocumentation]);
const displayDocumentation = ( const displayDocumentation = (
client: any, client: any,

Loading…
Cancel
Save