From 9919df1b068e81868d8ccea496165c5b71d9917c Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Thu, 16 Mar 2023 12:26:22 +0100 Subject: [PATCH] address comments from @lianahus and @bunsentraat --- .gitignore | 4 --- apps/doc-gen/src/app/App.tsx | 5 ++-- apps/doc-gen/src/app/docgen-client.ts | 6 ++-- .../src/app/docgen/common/properties.ts | 28 +++++++++---------- apps/doc-gen/src/app/docgen/site.ts | 10 +++---- apps/doc-gen/src/app/docgen/templates.ts | 11 ++------ apps/doc-gen/src/index.html | 1 - apps/doc-gen/webpack.config.js | 5 +--- apps/doc-viewer/src/index.html | 1 - apps/doc-viewer/webpack.config.js | 5 +--- tsconfig.paths.json | 3 -- 11 files changed, 28 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index d25f01c767..ad98096af7 100644 --- a/.gitignore +++ b/.gitignore @@ -57,7 +57,3 @@ testem.log .DS_Store .vscode/settings.json .vscode/launch.json -libs/remix-node/ -libs/remix-niks/ - -apps/remix-react diff --git a/apps/doc-gen/src/app/App.tsx b/apps/doc-gen/src/app/App.tsx index 010f2dec30..358d6776b6 100644 --- a/apps/doc-gen/src/app/App.tsx +++ b/apps/doc-gen/src/app/App.tsx @@ -35,9 +35,8 @@ const App = () => {

Remix Docgen

{fileName &&

File: {fileName.split('/')[1].split('.')[0].concat('.sol')}

} {hasBuild && } - ) -}; +} -export default App; +export default App diff --git a/apps/doc-gen/src/app/docgen-client.ts b/apps/doc-gen/src/app/docgen-client.ts index de0385f41d..76d702c6b4 100644 --- a/apps/doc-gen/src/app/docgen-client.ts +++ b/apps/doc-gen/src/app/docgen-client.ts @@ -5,7 +5,7 @@ import EventEmitter from 'events' import { Config, defaults } from './docgen/config' import { Build, buildSite } from './docgen/site' import { loadTemplates } from './docgen/templates' -import {SolcInput, SolcOutput} from 'solidity-ast/solc' +import { SolcInput, SolcOutput } from 'solidity-ast/solc' import { render } from './docgen/render' export class DocGenClient extends PluginClient { @@ -47,7 +47,6 @@ export class DocGenClient extends PluginClient { } this.fileName = fileName this.eventEmitter.emit('compilationFinished', this.build, fileName) - }) } @@ -78,5 +77,4 @@ export class DocGenClient extends PluginClient { async generateDocs() { this.docgen([this.build]) } - -} \ No newline at end of file +} diff --git a/apps/doc-gen/src/app/docgen/common/properties.ts b/apps/doc-gen/src/app/docgen/common/properties.ts index 3eb9919cd3..460090a036 100644 --- a/apps/doc-gen/src/app/docgen/common/properties.ts +++ b/apps/doc-gen/src/app/docgen/common/properties.ts @@ -10,11 +10,11 @@ import { itemType } from '../utils/item-type'; type TypeDefinition = StructDefinition | EnumDefinition | UserDefinedValueTypeDefinition; -export function type({ item }: DocItemContext): string { +export function type ({ item }: DocItemContext): string { return itemType(item); } -export function natspec({ item }: DocItemContext): NatSpec { +export function natspec ({ item }: DocItemContext): NatSpec { return parseNatspec(item); } @@ -26,7 +26,7 @@ export function name({ item }: DocItemContext, original?: unknown): string { } } -export function fullName({ item, contract }: DocItemContext): string { +export function fullName ({ item, contract }: DocItemContext): string { if (contract) { return `${contract.name}.${item.name}`; } else { @@ -34,7 +34,7 @@ export function fullName({ item, contract }: DocItemContext): string { } } -export function signature({ item }: DocItemContext): string | undefined { +export function signature ({ item }: DocItemContext): string | undefined { switch (item.nodeType) { case 'ContractDefinition': return undefined; @@ -85,7 +85,7 @@ interface Param extends VariableDeclaration { natspec?: string; }; -function getParams(params: ParameterList, natspec: NatSpec['params'] | NatSpec['returns']): Param[] { +function getParams (params: ParameterList, natspec: NatSpec['params'] | NatSpec['returns']): Param[] { return params.parameters.map((p, i) => ({ ...p, type: p.typeDescriptions.typeString!, @@ -93,46 +93,46 @@ function getParams(params: ParameterList, natspec: NatSpec['params'] | NatSpec[' })); } -export function params({ item }: DocItemContext): Param[] | undefined { +export function params ({ item }: DocItemContext): Param[] | undefined { if ('parameters' in item) { return getParams(item.parameters, natspec(item[DOC_ITEM_CONTEXT]).params); } } -export function returns({ item }: DocItemContext): Param[] | undefined { +export function returns ({ item }: DocItemContext): Param[] | undefined { if ('returnParameters' in item) { return getParams(item.returnParameters, natspec(item[DOC_ITEM_CONTEXT]).returns); } } -export function items({ item }: DocItemContext): DocItem[] | undefined { +export function items ({ item }: DocItemContext): DocItem[] | undefined { return (item.nodeType === 'ContractDefinition') ? item.nodes.filter(isNodeType(docItemTypes)).filter(n => !('visibility' in n) || n.visibility !== 'private') : undefined; } -export function functions({ item }: DocItemContext): FunctionDefinition[] | undefined { +export function functions ({ item }: DocItemContext): FunctionDefinition[] | undefined { return [...findAll('FunctionDefinition', item)].filter(f => f.visibility !== 'private'); } -export function events({ item }: DocItemContext): EventDefinition[] | undefined { +export function events ({ item }: DocItemContext): EventDefinition[] | undefined { return [...findAll('EventDefinition', item)]; } -export function modifiers({ item }: DocItemContext): ModifierDefinition[] | undefined { +export function modifiers ({ item }: DocItemContext): ModifierDefinition[] | undefined { return [...findAll('ModifierDefinition', item)]; } -export function errors({ item }: DocItemContext): ErrorDefinition[] | undefined { +export function errors ({ item }: DocItemContext): ErrorDefinition[] | undefined { return [...findAll('ErrorDefinition', item)]; } -export function variables({ item }: DocItemContext): VariableDeclaration[] | undefined { +export function variables ({ item }: DocItemContext): VariableDeclaration[] | undefined { return (item.nodeType === 'ContractDefinition') ? item.nodes.filter(isNodeType('VariableDeclaration')).filter(v => v.stateVariable && v.visibility !== 'private') : undefined; } -export function types({ item }: DocItemContext): TypeDefinition[] | undefined { +export function types ({ item }: DocItemContext): TypeDefinition[] | undefined { return [...findAll(['StructDefinition', 'EnumDefinition', 'UserDefinedValueTypeDefinition'], item)]; } diff --git a/apps/doc-gen/src/app/docgen/site.ts b/apps/doc-gen/src/app/docgen/site.ts index 90d63647a4..53ffd5bc92 100644 --- a/apps/doc-gen/src/app/docgen/site.ts +++ b/apps/doc-gen/src/app/docgen/site.ts @@ -52,7 +52,7 @@ export interface DocItemContext { build: BuildContext; } -export function buildSite(builds: Build[], siteConfig: SiteConfig, properties: Properties = {}): Site { +export function buildSite (builds: Build[], siteConfig: SiteConfig, properties: Properties = {}): Site { const assign = typeof siteConfig.pages === 'string' ? pageAssigner[siteConfig.pages] : siteConfig.pages; const seen = new Set(); @@ -106,20 +106,20 @@ export function buildSite(builds: Build[], siteConfig: SiteConfig, properties: P }; } -function defineContext(item: DocItem, build: BuildContext, file: SourceUnit, page?: string, contract?: ContractDefinition): DocItemWithContext { +function defineContext (item: DocItem, build: BuildContext, file: SourceUnit, page?: string, contract?: ContractDefinition): DocItemWithContext { return Object.assign(item, { [DOC_ITEM_CONTEXT]: { build, file, contract, page, item: item as DocItemWithContext }, }); } -function defineProperties(item: DocItemWithContext, properties: Properties) { +function defineProperties (item: DocItemWithContext, properties: Properties) { for (const [prop, fn] of Object.entries(properties)) { const original: unknown = (item as any)[prop]; defineGetterMemoized(item as any, prop, () => fn(item.__item_context, original)); } } -function assignIfIncludedSource( +function assignIfIncludedSource ( assign: PageAssigner, item: DocItem, file: SourceUnit, @@ -130,7 +130,7 @@ function assignIfIncludedSource( : undefined; } -function isFileIncluded(file: string, config: SiteConfig) { +function isFileIncluded (file: string, config: SiteConfig) { return ( isChild(file, config.sourcesDir) && config.exclude.every(e => !isChild(file, path.join(config.sourcesDir, e))) diff --git a/apps/doc-gen/src/app/docgen/templates.ts b/apps/doc-gen/src/app/docgen/templates.ts index 7f6a43b308..cee8f12c75 100644 --- a/apps/doc-gen/src/app/docgen/templates.ts +++ b/apps/doc-gen/src/app/docgen/templates.ts @@ -84,12 +84,7 @@ async function readHelpers(name: string) { * can't be imported directly. */ async function readThemes(): Promise>> { - const themes: Record> = {}; - - - - themes['markdown'] = await readTemplates(); - - - return themes; + const themes: Record> = {} + themes['markdown'] = await readTemplates() + return themes } diff --git a/apps/doc-gen/src/index.html b/apps/doc-gen/src/index.html index 7d7781859d..6e26b4393e 100644 --- a/apps/doc-gen/src/index.html +++ b/apps/doc-gen/src/index.html @@ -4,7 +4,6 @@ Remix Docgen - diff --git a/apps/doc-gen/webpack.config.js b/apps/doc-gen/webpack.config.js index 3cd446f615..7b3d088f05 100644 --- a/apps/doc-gen/webpack.config.js +++ b/apps/doc-gen/webpack.config.js @@ -40,8 +40,6 @@ module.exports = composePlugins(withNx(), withReact(), (config) => { // add public path config.output.publicPath = '/' - - // add copy & provide plugin config.plugins.push( new webpack.ProvidePlugin({ @@ -63,7 +61,6 @@ module.exports = composePlugins(withNx(), withReact(), (config) => { config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings - // set minimizer config.optimization.minimizer = [ new TerserPlugin({ @@ -82,4 +79,4 @@ module.exports = composePlugins(withNx(), withReact(), (config) => { ]; return config; -}); +}) diff --git a/apps/doc-viewer/src/index.html b/apps/doc-viewer/src/index.html index 7fd033d57e..ab3b67eef1 100644 --- a/apps/doc-viewer/src/index.html +++ b/apps/doc-viewer/src/index.html @@ -4,7 +4,6 @@ Doc Viewer - diff --git a/apps/doc-viewer/webpack.config.js b/apps/doc-viewer/webpack.config.js index 3cd446f615..7b3d088f05 100644 --- a/apps/doc-viewer/webpack.config.js +++ b/apps/doc-viewer/webpack.config.js @@ -40,8 +40,6 @@ module.exports = composePlugins(withNx(), withReact(), (config) => { // add public path config.output.publicPath = '/' - - // add copy & provide plugin config.plugins.push( new webpack.ProvidePlugin({ @@ -63,7 +61,6 @@ module.exports = composePlugins(withNx(), withReact(), (config) => { config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings - // set minimizer config.optimization.minimizer = [ new TerserPlugin({ @@ -82,4 +79,4 @@ module.exports = composePlugins(withNx(), withReact(), (config) => { ]; return config; -}); +}) diff --git a/tsconfig.paths.json b/tsconfig.paths.json index 20989bfbd2..dec19c068b 100644 --- a/tsconfig.paths.json +++ b/tsconfig.paths.json @@ -148,9 +148,6 @@ "@remix-ui/solidity-uml-gen": [ "libs/remix-ui/solidity-uml-gen/src/index.ts" ], - "@remix-ui/docgenclient-ui": [ - "libs/remix-ui/docgenclient-ui/src/index.ts" - ], "@remix-project/ghaction-helper": [ "libs/ghaction-helper/src/index.ts" ],