address comments from @lianahus and @bunsentraat

pull/3475/head
Joseph Izang 2 years ago committed by Aniket
parent 398013314a
commit 3117afe3b2
  1. 4
      .gitignore
  2. 5
      apps/doc-gen/src/app/App.tsx
  3. 6
      apps/doc-gen/src/app/docgen-client.ts
  4. 28
      apps/doc-gen/src/app/docgen/common/properties.ts
  5. 10
      apps/doc-gen/src/app/docgen/site.ts
  6. 11
      apps/doc-gen/src/app/docgen/templates.ts
  7. 1
      apps/doc-gen/src/index.html
  8. 5
      apps/doc-gen/webpack.config.js
  9. 1
      apps/doc-viewer/src/index.html
  10. 5
      apps/doc-viewer/webpack.config.js
  11. 3
      tsconfig.paths.json

4
.gitignore vendored

@ -57,7 +57,3 @@ testem.log
.DS_Store
.vscode/settings.json
.vscode/launch.json
libs/remix-node/
libs/remix-niks/
apps/remix-react

@ -35,9 +35,8 @@ const App = () => {
<h1>Remix Docgen</h1>
{fileName && <h4>File: {fileName.split('/')[1].split('.')[0].concat('.sol')}</h4>}
{hasBuild && <button className="btn btn-primary btn-block mt-4 rounded" onClick={() => client.generateDocs()}>Generate doc</button>}
</div>
)
};
}
export default App;
export default App

@ -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])
}
}
}

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

@ -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<string>();
@ -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)))

@ -84,12 +84,7 @@ async function readHelpers(name: string) {
* can't be imported directly.
*/
async function readThemes(): Promise<Record<string, Required<Templates>>> {
const themes: Record<string, Required<Templates>> = {};
themes['markdown'] = await readTemplates();
return themes;
const themes: Record<string, Required<Templates>> = {}
themes['markdown'] = await readTemplates()
return themes
}

@ -4,7 +4,6 @@
<meta charset="utf-8" />
<title>Remix Docgen</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>

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

@ -4,7 +4,6 @@
<meta charset="utf-8" />
<title>Doc Viewer</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>

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

@ -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"
],

Loading…
Cancel
Save