@rocketh/doc 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ dist/
2
+ node_modules/
3
+ package.json
4
+ *.hbs
package/.prettierrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "useTabs": true,
3
+ "singleQuote": true,
4
+
5
+ "printWidth": 120,
6
+ "bracketSpacing": false
7
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # @rocketh/doc
2
+
3
+ ## 0.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - use pkgroll and @rocketh namespace
8
+ - Updated dependencies
9
+ - rocketh@0.10.9
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # rocketh-doc
2
+
3
+ `rocketh-doc` generates documentation from deployments files, following rocketh format composed of address,abi, etc....
4
+
5
+ There is plan to support doc generation from compiled artifacts too, but no work has started on that.
6
+
7
+ We welcome contribution if you are interested to support that feature.
8
+
9
+ For now rocketh-doc is intended to be used to document a set of deployed contract.
10
+
11
+ Note that documentation template (written in handlebars) have access to the deployment address.
package/dist/cli.cjs ADDED
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var rocketh = require('rocketh');
5
+ var index = require('./index.cjs');
6
+ var commander = require('commander');
7
+ require('fs-extra');
8
+ require('handlebars');
9
+ require('path');
10
+ require('ethers');
11
+ require('url');
12
+
13
+ var name = "@rocketh/doc";
14
+ var version = "0.10.0";
15
+ var description = "can generate doc from rocketh deployments and provided template";
16
+ var publishConfig = {
17
+ access: "public"
18
+ };
19
+ var type = "module";
20
+ var main = "dist/index.cjs";
21
+ var module$1 = "dist/index.mjs";
22
+ var types = "dist/index.d.ts";
23
+ var bin = {
24
+ "rocketh-doc": "dist/cli.cjs"
25
+ };
26
+ var devDependencies = {
27
+ "@types/node": "^20.12.7",
28
+ pkgroll: "^2.0.2",
29
+ rimraf: "^5.0.5",
30
+ rocketh: "workspace:*",
31
+ typescript: "^5.4.5"
32
+ };
33
+ var peerDependencies = {
34
+ rocketh: "workspace:*"
35
+ };
36
+ var dependencies = {
37
+ "@types/fs-extra": "^11.0.4",
38
+ commander: "^12.0.0",
39
+ ethers: "^6.11.1",
40
+ "fs-extra": "^11.2.0",
41
+ handlebars: "^4.7.8"
42
+ };
43
+ var scripts = {
44
+ build: "rimraf dist && pkgroll --sourcemap",
45
+ dev: "pkgroll --watch"
46
+ };
47
+ var pkg = {
48
+ name: name,
49
+ version: version,
50
+ description: description,
51
+ publishConfig: publishConfig,
52
+ type: type,
53
+ main: main,
54
+ module: module$1,
55
+ types: types,
56
+ ".": {
57
+ require: {
58
+ types: "./dist/index.d.ts",
59
+ "default": "./dist/index.cjs"
60
+ },
61
+ "import": {
62
+ types: "./dist/index.d.ts",
63
+ "default": "./dist/index.mjs"
64
+ }
65
+ },
66
+ bin: bin,
67
+ devDependencies: devDependencies,
68
+ peerDependencies: peerDependencies,
69
+ dependencies: dependencies,
70
+ scripts: scripts
71
+ };
72
+
73
+ const commandName = pkg.name;
74
+ const program = new commander.Command();
75
+ program.name(commandName).description("generate doc from deployments and provided templates").version(pkg.version).option("-d, --deployments <value>", "folder where deployments are saved").option("-o, --output <value>", "folder where to generate docs").option("-t, --template <value>", "template used to generate docs").option("--except-suffix <suffix, suffix....>", "ignore contract that ends with the provided suffixes").requiredOption("-n, --network <value>", "network context to use").parse(process.argv);
76
+ const options = program.opts();
77
+ options.exceptSuffix = options.exceptSuffix.split(",");
78
+ const resolvedConfig = rocketh.readAndResolveConfig(options);
79
+ index.run(resolvedConfig, options);
80
+ //# sourceMappingURL=cli.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.cjs","sources":["../src/cli.ts"],"sourcesContent":["#! /usr/bin/env node\nimport {readAndResolveConfig} from 'rocketh';\nimport {run} from '.';\nimport {Command} from 'commander';\nimport pkg from '../package.json';\nimport {ConfigOptions} from 'rocketh';\nimport {RunOptions} from '.';\n\nconst commandName = pkg.name;\n\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.description('generate doc from deployments and provided templates')\n\t.version(pkg.version)\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t.option('-o, --output <value>', 'folder where to generate docs')\n\t.option('-t, --template <value>', 'template used to generate docs')\n\t.option('--except-suffix <suffix, suffix....>', 'ignore contract that ends with the provided suffixes')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\noptions.exceptSuffix = options.exceptSuffix.split(',');\nconst resolvedConfig = readAndResolveConfig(options as ConfigOptions);\nrun(resolvedConfig, options as RunOptions);\n"],"names":["Command","readAndResolveConfig","run"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAG,CAAG,CAAA,CAAA,CAAC,IAAI,CAAC;AAC7B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAG,CAAIA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAO,EAAE,CAAA;AAC7B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,C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,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA"}
package/dist/cli.mjs ADDED
@@ -0,0 +1,77 @@
1
+ import { readAndResolveConfig } from 'rocketh';
2
+ import { run } from './index.mjs';
3
+ import { Command } from 'commander';
4
+ import 'fs-extra';
5
+ import 'handlebars';
6
+ import 'path';
7
+ import 'ethers';
8
+ import 'url';
9
+
10
+ var name = "@rocketh/doc";
11
+ var version = "0.10.0";
12
+ var description = "can generate doc from rocketh deployments and provided template";
13
+ var publishConfig = {
14
+ access: "public"
15
+ };
16
+ var type = "module";
17
+ var main = "dist/index.cjs";
18
+ var module = "dist/index.mjs";
19
+ var types = "dist/index.d.ts";
20
+ var bin = {
21
+ "rocketh-doc": "dist/cli.cjs"
22
+ };
23
+ var devDependencies = {
24
+ "@types/node": "^20.12.7",
25
+ pkgroll: "^2.0.2",
26
+ rimraf: "^5.0.5",
27
+ rocketh: "workspace:*",
28
+ typescript: "^5.4.5"
29
+ };
30
+ var peerDependencies = {
31
+ rocketh: "workspace:*"
32
+ };
33
+ var dependencies = {
34
+ "@types/fs-extra": "^11.0.4",
35
+ commander: "^12.0.0",
36
+ ethers: "^6.11.1",
37
+ "fs-extra": "^11.2.0",
38
+ handlebars: "^4.7.8"
39
+ };
40
+ var scripts = {
41
+ build: "rimraf dist && pkgroll --sourcemap",
42
+ dev: "pkgroll --watch"
43
+ };
44
+ var pkg = {
45
+ name: name,
46
+ version: version,
47
+ description: description,
48
+ publishConfig: publishConfig,
49
+ type: type,
50
+ main: main,
51
+ module: module,
52
+ types: types,
53
+ ".": {
54
+ require: {
55
+ types: "./dist/index.d.ts",
56
+ "default": "./dist/index.cjs"
57
+ },
58
+ "import": {
59
+ types: "./dist/index.d.ts",
60
+ "default": "./dist/index.mjs"
61
+ }
62
+ },
63
+ bin: bin,
64
+ devDependencies: devDependencies,
65
+ peerDependencies: peerDependencies,
66
+ dependencies: dependencies,
67
+ scripts: scripts
68
+ };
69
+
70
+ const commandName = pkg.name;
71
+ const program = new Command();
72
+ program.name(commandName).description("generate doc from deployments and provided templates").version(pkg.version).option("-d, --deployments <value>", "folder where deployments are saved").option("-o, --output <value>", "folder where to generate docs").option("-t, --template <value>", "template used to generate docs").option("--except-suffix <suffix, suffix....>", "ignore contract that ends with the provided suffixes").requiredOption("-n, --network <value>", "network context to use").parse(process.argv);
73
+ const options = program.opts();
74
+ options.exceptSuffix = options.exceptSuffix.split(",");
75
+ const resolvedConfig = readAndResolveConfig(options);
76
+ run(resolvedConfig, options);
77
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.mjs","sources":["../src/cli.ts"],"sourcesContent":["#! /usr/bin/env node\nimport {readAndResolveConfig} from 'rocketh';\nimport {run} from '.';\nimport {Command} from 'commander';\nimport pkg from '../package.json';\nimport {ConfigOptions} from 'rocketh';\nimport {RunOptions} from '.';\n\nconst commandName = pkg.name;\n\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.description('generate doc from deployments and provided templates')\n\t.version(pkg.version)\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t.option('-o, --output <value>', 'folder where to generate docs')\n\t.option('-t, --template <value>', 'template used to generate docs')\n\t.option('--except-suffix <suffix, suffix....>', 'ignore contract that ends with the provided suffixes')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\noptions.exceptSuffix = options.exceptSuffix.split(',');\nconst resolvedConfig = readAndResolveConfig(options as ConfigOptions);\nrun(resolvedConfig, options as RunOptions);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC;AAC7B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAC7B,OAAA,CAAA,IAAA,CAAA,WAAA,CAAA,CAAA,WAAA,CAAA,sDAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA,2BAAA,EAAA,oCAAA,CAAA,CAAA,MAAA,CAAA,sBAAA,EAAA,+BAAA,CAAA,CAAA,MAAA,CAAA,wBAAA,EAAA,gCAAA,CAAA,CAAA,MAAA,CAAA,sCAAA,EAAA,sDAAA,CAAA,CAAA,cAAA,CAAA,uBAAA,EAAA,wBAAA,CAAA,CAAA,KAAA,CAAA,OAAA,CAAA,IAAA,CAAA,CAAA;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAC,CAAA;AAC7B,OAAA,CAAA,YAAA,GAAA,OAAA,CAAA,YAAA,CAAA,KAAA,CAAA,GAAA,CAAA,CAAA;AACA,MAAM,cAAc,GAAG,oBAAO,CAAA,OAAA,CAAA,CAAA;AAC9B,GAAG,CAAC,cAAG,EAAA,OAAA,CAAA"}
package/dist/index.cjs ADDED
@@ -0,0 +1,248 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs-extra');
4
+ var rocketh = require('rocketh');
5
+ var Handlebars = require('handlebars');
6
+ var path = require('path');
7
+ var ethers = require('ethers');
8
+ var url = require('url');
9
+
10
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
+ const __dirname$1 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
12
+ function filter(options, name) {
13
+ if (options.exceptSuffix) {
14
+ for (const suffix of options.exceptSuffix) {
15
+ if (name.endsWith(suffix)) {
16
+ return false;
17
+ }
18
+ }
19
+ }
20
+ return true;
21
+ }
22
+ async function run(config, options) {
23
+ const { deployments, chainId } = rocketh.loadDeployments(config.deployments, config.network.name);
24
+ if (!chainId) {
25
+ throw new Error(`no chainId found for ${config.network.name}`);
26
+ }
27
+ generate({ deployments }, options);
28
+ }
29
+ async function generate({ deployments }, options) {
30
+ if (!deployments || Object.keys(deployments).length === 0) {
31
+ console.log(`no deployments to export`);
32
+ return;
33
+ }
34
+ const toDocument = {};
35
+ for (const name of Object.keys(deployments)) {
36
+ if (!filter(options, name)) {
37
+ continue;
38
+ }
39
+ const deployment = deployments[name];
40
+ toDocument[name] = deployment;
41
+ }
42
+ return generateFromDeployments(toDocument, options);
43
+ }
44
+ async function runFromFolder(folder, options) {
45
+ const files = fs.readdirSync(folder);
46
+ const deployments = {};
47
+ for (const file of files) {
48
+ if (file.endsWith(".json")) {
49
+ const name = path.basename(file, ".json");
50
+ if (!filter(options, name)) {
51
+ continue;
52
+ }
53
+ const deploymentString = fs.readFileSync(path.join(folder, file), "utf-8");
54
+ const deployment = JSON.parse(deploymentString);
55
+ deployments[name] = deployment;
56
+ }
57
+ }
58
+ return generateFromDeployments(deployments, options);
59
+ }
60
+ async function generateFromDeployments(deployments, options) {
61
+ const outputFolder = options.output || "docs";
62
+ const templateFilepath = options.template || path.join(__dirname$1, "default_templates/{{contracts}}.hbs");
63
+ const templateName = path.basename(templateFilepath, ".hbs");
64
+ const templateContent = fs.readFileSync(templateFilepath, "utf-8");
65
+ const template = Handlebars.compile(templateContent);
66
+ const deploymentsList = [];
67
+ for (const name of Object.keys(deployments)) {
68
+ const deployment = deployments[name];
69
+ const data = generateDocumentationData(name, deployment);
70
+ deploymentsList.push(data);
71
+ }
72
+ fs.emptyDirSync(outputFolder);
73
+ if (templateName === "{{contracts}}") {
74
+ for (const deployment of deploymentsList) {
75
+ const generated = template(deployment);
76
+ if (generated.trim() !== "") {
77
+ fs.writeFileSync(path.join(outputFolder, deployment.name + ".md"), generated);
78
+ }
79
+ }
80
+ } else {
81
+ const generated = template({ contracts: deploymentsList });
82
+ fs.writeFileSync(path.join(outputFolder, templateName + ".md"), generated);
83
+ }
84
+ }
85
+ function generateDocumentationData(name, deploymentOrArfifact) {
86
+ const abi = deploymentOrArfifact.abi;
87
+ const abiMap = /* @__PURE__ */ new Map();
88
+ for (const abiElement of abi) {
89
+ switch (abiElement.type) {
90
+ case "constructor":
91
+ abiMap.set("constructor", abiElement);
92
+ break;
93
+ case "error":
94
+ abiMap.set(abiElement.name, abiElement);
95
+ break;
96
+ case "event":
97
+ abiMap.set(abiElement.name, abiElement);
98
+ break;
99
+ case "function":
100
+ abiMap.set(abiElement.name, abiElement);
101
+ break;
102
+ }
103
+ }
104
+ const errors = [];
105
+ const events = [];
106
+ const methods = [];
107
+ if (deploymentOrArfifact.userdoc?.errors) {
108
+ for (const errorSignature of Object.keys(deploymentOrArfifact.userdoc.errors)) {
109
+ const errorName = errorSignature.indexOf("(") > 0 ? errorSignature.slice(0, errorSignature.indexOf("(")) : errorSignature;
110
+ const abi2 = abiMap.get(errorName);
111
+ if (!abi2) {
112
+ continue;
113
+ }
114
+ const fullFormat = ethers.Fragment.from(abi2).format("full");
115
+ const paramNames = abi2.inputs.map((v, index) => v.name || `_${index}`);
116
+ const errorFromUserDoc = deploymentOrArfifact.userdoc.errors[errorSignature];
117
+ const errorFromDevDoc = deploymentOrArfifact.devdoc?.errors?.[errorSignature];
118
+ const params = [];
119
+ if (errorFromDevDoc) {
120
+ for (const doc of errorFromDevDoc) {
121
+ if (doc.params) {
122
+ for (const paramName of paramNames || Object.keys(doc.params)) {
123
+ params.push({ name: paramName, description: doc.params[paramName] });
124
+ }
125
+ }
126
+ }
127
+ }
128
+ const notice = [];
129
+ if (errorFromUserDoc) {
130
+ for (const doc of errorFromUserDoc) {
131
+ if (doc.notice) {
132
+ const notes = doc.notice.split("\\");
133
+ for (const note of notes) {
134
+ if (note != "") {
135
+ notice.push(note);
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
141
+ errors.push({
142
+ name: errorName,
143
+ signature: errorSignature,
144
+ abi: abi2,
145
+ fullFormat,
146
+ notice,
147
+ params
148
+ });
149
+ }
150
+ }
151
+ if (deploymentOrArfifact.userdoc?.events) {
152
+ for (const eventSignature of Object.keys(deploymentOrArfifact.userdoc.events)) {
153
+ const eventName = eventSignature.indexOf("(") > 0 ? eventSignature.slice(0, eventSignature.indexOf("(")) : eventSignature;
154
+ const abi2 = abiMap.get(eventName);
155
+ if (!abi2) {
156
+ continue;
157
+ }
158
+ const fullFormat = ethers.Fragment.from(abi2).format("full");
159
+ const paramNames = abi2.inputs.map((v, index) => v.name || `_${index}`);
160
+ const eventFromUserDoc = deploymentOrArfifact.userdoc.events[eventSignature];
161
+ const eventFromDevDoc = deploymentOrArfifact.devdoc?.events?.[eventSignature];
162
+ const params = [];
163
+ if (eventFromDevDoc?.params) {
164
+ for (const paramName of paramNames || Object.keys(eventFromDevDoc.params)) {
165
+ params.push({ name: paramName, description: eventFromDevDoc.params[paramName] });
166
+ }
167
+ }
168
+ events.push({
169
+ name: eventName,
170
+ signature: eventSignature,
171
+ abi: abi2,
172
+ fullFormat,
173
+ notice: eventFromUserDoc.notice,
174
+ params
175
+ });
176
+ }
177
+ }
178
+ if (deploymentOrArfifact.userdoc?.methods) {
179
+ for (const methodSignature of Object.keys(deploymentOrArfifact.userdoc.methods)) {
180
+ const methodName = methodSignature.indexOf("(") > 0 ? methodSignature.slice(0, methodSignature.indexOf("(")) : methodSignature;
181
+ const abi2 = abiMap.get(methodName);
182
+ if (!abi2) {
183
+ continue;
184
+ }
185
+ const fullFormat = ethers.Fragment.from(abi2).format("full");
186
+ const paramNames = abi2 ? abi2.inputs.map((v, index) => v.name || `_${index}`) : void 0;
187
+ const returnNames = abi2 && "outputs" in abi2 ? abi2.outputs.map((v, index) => v.name || `_${index}`) : void 0;
188
+ const methodFromUserDoc = deploymentOrArfifact.userdoc.methods[methodSignature];
189
+ const methodFromDevDoc = deploymentOrArfifact.devdoc?.methods?.[methodSignature];
190
+ const params = [];
191
+ if (methodFromDevDoc?.params) {
192
+ for (const paramName of paramNames || Object.keys(methodFromDevDoc.params)) {
193
+ params.push({ name: paramName, description: methodFromDevDoc.params[paramName] });
194
+ }
195
+ }
196
+ const returns = [];
197
+ if (methodFromDevDoc?.returns) {
198
+ for (const returnName of returnNames || Object.keys(methodFromDevDoc.returns)) {
199
+ returns.push({ name: returnName, description: methodFromDevDoc.returns[returnName] });
200
+ }
201
+ }
202
+ if (methodName === "constructor") {
203
+ methods.push({
204
+ type: "constructor",
205
+ name: "constructor",
206
+ abi: abi2,
207
+ signature: methodSignature,
208
+ fullFormat,
209
+ notice: methodFromUserDoc.notice,
210
+ params,
211
+ returns
212
+ });
213
+ } else {
214
+ const selector = ethers.FunctionFragment.from(abi2).selector;
215
+ methods.push({
216
+ type: "function",
217
+ name: methodName,
218
+ abi: abi2,
219
+ signature: methodSignature,
220
+ fullFormat,
221
+ bytes4: selector,
222
+ notice: methodFromUserDoc.notice,
223
+ params,
224
+ returns
225
+ });
226
+ }
227
+ }
228
+ }
229
+ const data = {
230
+ name,
231
+ address: deploymentOrArfifact.address,
232
+ abi,
233
+ author: deploymentOrArfifact.devdoc?.author,
234
+ title: deploymentOrArfifact.devdoc?.title,
235
+ notice: deploymentOrArfifact.userdoc?.notice,
236
+ errors,
237
+ events,
238
+ methods
239
+ };
240
+ return data;
241
+ }
242
+
243
+ exports.generate = generate;
244
+ exports.generateDocumentationData = generateDocumentationData;
245
+ exports.generateFromDeployments = generateFromDeployments;
246
+ exports.run = run;
247
+ exports.runFromFolder = runFromFolder;
248
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport type {\n\tDeployment,\n\tResolvedConfig,\n\tNoticeUserDoc,\n\tArtifact,\n\tAbi,\n\tUnknownDeployments,\n\tAbiConstructor,\n\tAbiFunction,\n\tAbiError,\n\tAbiEvent,\n} from 'rocketh';\nimport {loadDeployments} from 'rocketh';\nimport Handlebars from 'handlebars';\nimport path from 'path';\nimport {Fragment, FunctionFragment} from 'ethers';\nimport {dirname} from 'path';\nimport {fileURLToPath} from 'url';\n\nimport {DocumentationData, ErrorDoc, EventDoc, MethodDoc, ParamDoc, ReturnDoc} from './types';\n\nexport * from './types';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport type RunOptions = {template?: string; output?: string; exceptSuffix?: string[]};\n\nfunction filter(options: RunOptions, name: string): boolean {\n\tif (options.exceptSuffix) {\n\t\tfor (const suffix of options.exceptSuffix) {\n\t\t\tif (name.endsWith(suffix)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\nexport async function run(config: ResolvedConfig, options: RunOptions) {\n\tconst {deployments, chainId} = loadDeployments(config.deployments, config.network.name);\n\tif (!chainId) {\n\t\tthrow new Error(`no chainId found for ${config.network.name}`);\n\t}\n\tgenerate({deployments}, options);\n}\n\nexport async function generate(\n\t{deployments}: {deployments: UnknownDeployments; chainId?: string},\n\toptions: RunOptions\n) {\n\tif (!deployments || Object.keys(deployments).length === 0) {\n\t\tconsole.log(`no deployments to export`);\n\t\treturn;\n\t}\n\n\tconst toDocument: UnknownDeployments = {};\n\tfor (const name of Object.keys(deployments)) {\n\t\tif (!filter(options, name)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst deployment = deployments[name];\n\t\ttoDocument[name] = deployment;\n\t}\n\n\treturn generateFromDeployments(toDocument, options);\n}\n\nexport async function runFromFolder(folder: string, options: RunOptions) {\n\tconst files = fs.readdirSync(folder);\n\tconst deployments: UnknownDeployments = {};\n\tfor (const file of files) {\n\t\tif (file.endsWith('.json')) {\n\t\t\tconst name = path.basename(file, '.json');\n\t\t\tif (!filter(options, name)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst deploymentString = fs.readFileSync(path.join(folder, file), 'utf-8');\n\t\t\tconst deployment = JSON.parse(deploymentString);\n\t\t\tdeployments[name] = deployment;\n\t\t}\n\t}\n\n\treturn generateFromDeployments(deployments, options);\n}\n\n// export async function runFromArtifacts(folder: string, options: {template?: string; outputFolder?: string}) {\n// \tconst files = fs.readdirSync(folder);\n// \tconst deployments: UnknownDeployments = {};\n// \tfor (const file of files) {\n// \t\tif (file.endsWith('.json')) {\n// \t\t\tconst deploymentString = fs.readFileSync(path.join(folder, file), 'utf-8');\n// \t\t\tconst deployment = JSON.parse(deploymentString);\n// \t\t\tdeployments[path.basename(file, '.json')] = deployment;\n// \t\t}\n// \t}\n\n// \treturn generateFromDeployments(deployments, options);\n// }\n\nexport async function generateFromDeployments(deployments: UnknownDeployments, options: RunOptions) {\n\tconst outputFolder = options.output || 'docs';\n\tconst templateFilepath = options.template || path.join(__dirname, 'default_templates/{{contracts}}.hbs');\n\tconst templateName = path.basename(templateFilepath, '.hbs');\n\tconst templateContent = fs.readFileSync(templateFilepath, 'utf-8');\n\tconst template = Handlebars.compile(templateContent);\n\n\tconst deploymentsList: DocumentationData[] = [];\n\tfor (const name of Object.keys(deployments)) {\n\t\tconst deployment = deployments[name];\n\t\tconst data = generateDocumentationData(name, deployment);\n\t\tdeploymentsList.push(data);\n\t}\n\n\tfs.emptyDirSync(outputFolder);\n\tif (templateName === '{{contracts}}') {\n\t\tfor (const deployment of deploymentsList) {\n\t\t\tconst generated = template(deployment);\n\t\t\tif (generated.trim() !== '') {\n\t\t\t\tfs.writeFileSync(path.join(outputFolder, deployment.name + '.md'), generated);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst generated = template({contracts: deploymentsList});\n\t\tfs.writeFileSync(path.join(outputFolder, templateName + '.md'), generated);\n\t}\n}\n\nexport function generateDocumentationData(\n\tname: string,\n\tdeploymentOrArfifact: Partial<Deployment<Abi>> & Artifact<Abi>\n): DocumentationData {\n\tconst abi = deploymentOrArfifact.abi;\n\tconst abiMap = new Map<string, AbiConstructor | AbiError | AbiEvent | AbiFunction>();\n\tfor (const abiElement of abi) {\n\t\tswitch (abiElement.type) {\n\t\t\tcase 'constructor':\n\t\t\t\tabiMap.set('constructor', abiElement);\n\t\t\t\tbreak;\n\t\t\tcase 'error':\n\t\t\t\tabiMap.set(abiElement.name, abiElement);\n\t\t\t\tbreak;\n\t\t\tcase 'event':\n\t\t\t\tabiMap.set(abiElement.name, abiElement);\n\t\t\t\tbreak;\n\t\t\tcase 'function':\n\t\t\t\tabiMap.set(abiElement.name, abiElement);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst errors: ErrorDoc[] = [];\n\tconst events: EventDoc[] = [];\n\tconst methods: MethodDoc[] = [];\n\n\tif (deploymentOrArfifact.userdoc?.errors) {\n\t\t// we loop only through userdoc\n\t\tfor (const errorSignature of Object.keys(deploymentOrArfifact.userdoc.errors)) {\n\t\t\tconst errorName =\n\t\t\t\terrorSignature.indexOf('(') > 0 ? errorSignature.slice(0, errorSignature.indexOf('(')) : errorSignature;\n\n\t\t\tconst abi = abiMap.get(errorName) as AbiError;\n\t\t\tif (!abi) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst fullFormat = Fragment.from(abi).format('full');\n\t\t\tconst paramNames = abi.inputs.map((v, index) => v.name || `_${index}`);\n\n\t\t\tconst errorFromUserDoc = deploymentOrArfifact.userdoc.errors[errorSignature];\n\t\t\tconst errorFromDevDoc = deploymentOrArfifact.devdoc?.errors?.[errorSignature];\n\t\t\tconst params: ParamDoc[] = [];\n\t\t\tif (errorFromDevDoc) {\n\t\t\t\tfor (const doc of errorFromDevDoc) {\n\t\t\t\t\tif (doc.params) {\n\t\t\t\t\t\tfor (const paramName of paramNames || Object.keys(doc.params)) {\n\t\t\t\t\t\t\tparams.push({name: paramName, description: doc.params[paramName]});\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// TODO what if same name\n\t\t\t\t\t\t// TODO what is the array for ? (look at solidity doc)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst notice: string[] = [];\n\t\t\tif (errorFromUserDoc) {\n\t\t\t\tfor (const doc of errorFromUserDoc) {\n\t\t\t\t\tif (doc.notice) {\n\t\t\t\t\t\tconst notes = doc.notice.split('\\\\');\n\t\t\t\t\t\tfor (const note of notes) {\n\t\t\t\t\t\t\tif (note != '') {\n\t\t\t\t\t\t\t\tnotice.push(note);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\terrors.push({\n\t\t\t\tname: errorName,\n\t\t\t\tsignature: errorSignature,\n\t\t\t\tabi: abi,\n\t\t\t\tfullFormat,\n\t\t\t\tnotice,\n\t\t\t\tparams,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (deploymentOrArfifact.userdoc?.events) {\n\t\t// we loop only through userdoc\n\t\tfor (const eventSignature of Object.keys(deploymentOrArfifact.userdoc.events)) {\n\t\t\tconst eventName =\n\t\t\t\teventSignature.indexOf('(') > 0 ? eventSignature.slice(0, eventSignature.indexOf('(')) : eventSignature;\n\n\t\t\tconst abi = abiMap.get(eventName) as AbiEvent;\n\t\t\tif (!abi) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst fullFormat = Fragment.from(abi).format('full');\n\t\t\tconst paramNames = abi.inputs.map((v, index) => v.name || `_${index}`);\n\n\t\t\tconst eventFromUserDoc = deploymentOrArfifact.userdoc.events[eventSignature];\n\t\t\tconst eventFromDevDoc = deploymentOrArfifact.devdoc?.events?.[eventSignature];\n\t\t\tconst params: ParamDoc[] = [];\n\t\t\tif (eventFromDevDoc?.params) {\n\t\t\t\tfor (const paramName of paramNames || Object.keys(eventFromDevDoc.params)) {\n\t\t\t\t\tparams.push({name: paramName, description: eventFromDevDoc.params[paramName]});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tevents.push({\n\t\t\t\tname: eventName,\n\t\t\t\tsignature: eventSignature,\n\t\t\t\tabi: abi as AbiEvent,\n\t\t\t\tfullFormat,\n\t\t\t\tnotice: eventFromUserDoc.notice,\n\t\t\t\tparams,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (deploymentOrArfifact.userdoc?.methods) {\n\t\t// we loop only through userdoc\n\t\tfor (const methodSignature of Object.keys(deploymentOrArfifact.userdoc.methods)) {\n\t\t\tconst methodName =\n\t\t\t\tmethodSignature.indexOf('(') > 0 ? methodSignature.slice(0, methodSignature.indexOf('(')) : methodSignature;\n\n\t\t\tconst abi = abiMap.get(methodName) as AbiFunction | AbiConstructor;\n\t\t\tif (!abi) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst fullFormat = Fragment.from(abi).format('full');\n\t\t\tconst paramNames = abi ? abi.inputs.map((v, index) => v.name || `_${index}`) : undefined;\n\t\t\tconst returnNames = abi && 'outputs' in abi ? abi.outputs.map((v, index) => v.name || `_${index}`) : undefined;\n\n\t\t\tconst methodFromUserDoc = deploymentOrArfifact.userdoc.methods[methodSignature];\n\t\t\tconst methodFromDevDoc = deploymentOrArfifact.devdoc?.methods?.[methodSignature];\n\t\t\tconst params: ParamDoc[] = [];\n\t\t\tif (methodFromDevDoc?.params) {\n\t\t\t\tfor (const paramName of paramNames || Object.keys(methodFromDevDoc.params)) {\n\t\t\t\t\tparams.push({name: paramName, description: methodFromDevDoc.params[paramName]});\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst returns: ReturnDoc[] = [];\n\t\t\tif (methodFromDevDoc?.returns) {\n\t\t\t\tfor (const returnName of returnNames || Object.keys(methodFromDevDoc.returns)) {\n\t\t\t\t\treturns.push({name: returnName, description: methodFromDevDoc.returns[returnName]});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (methodName === 'constructor') {\n\t\t\t\tmethods.push({\n\t\t\t\t\ttype: 'constructor',\n\t\t\t\t\tname: 'constructor',\n\t\t\t\t\tabi: abi as AbiConstructor,\n\t\t\t\t\tsignature: methodSignature,\n\t\t\t\t\tfullFormat,\n\t\t\t\t\tnotice: methodFromUserDoc.notice,\n\t\t\t\t\tparams,\n\t\t\t\t\treturns,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst selector = FunctionFragment.from(abi).selector as `0x${string}`;\n\t\t\t\tmethods.push({\n\t\t\t\t\ttype: 'function',\n\t\t\t\t\tname: methodName,\n\t\t\t\t\tabi: abi as AbiFunction,\n\t\t\t\t\tsignature: methodSignature,\n\t\t\t\t\tfullFormat,\n\t\t\t\t\tbytes4: selector,\n\t\t\t\t\tnotice: methodFromUserDoc.notice,\n\t\t\t\t\tparams,\n\t\t\t\t\treturns,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tconst data: DocumentationData = {\n\t\tname,\n\t\taddress: deploymentOrArfifact.address,\n\t\tabi,\n\t\tauthor: deploymentOrArfifact.devdoc?.author,\n\t\ttitle: deploymentOrArfifact.devdoc?.title,\n\t\tnotice: deploymentOrArfifact.userdoc?.notice,\n\t\terrors,\n\t\tevents,\n\t\tmethods,\n\t};\n\treturn data;\n}\n"],"names":["__dirname","dirname","fileURLToPath","loadDeployments","Fragment","FunctionFragment"],"mappings":";;;;;;;;;;AASA,MAAMA,WAAS,GAAGC,YAAO,CAACC,iBAAa,CAAC,8LAAe,CAAC,CAAC,CAAC;AAC1D,SAAS,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE;AAC/B,EAAE,IAAI,OAAO,CAAC,YAAY,EAAE;AAC5B,IAAI,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE;AAC/C,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;AACjC,QAAQ,OAAO,KAAK,CAAC;AACrB,OAAO;AACP,KAAK;AACL,GAAG;AACH,EAAE,OAAO,IAAI,CAAC;AACd,CAAC;AACM,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE;AAC3C,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAGC,uBAAe,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC5F,EAAE,IAAI,CAAC,OAAO,EAAE;AAChB,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,qBAAqB,EAAE,MAAM,CAAC,OAAO,CAAC,IA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AAC,QAAQ,CAAC;AAC9D,QAAQ,OAAO,CAAC,IAAI,CAAC;AACrB,UAAU,IAAI,EAAE,UAAU;AAC1B,UAAU,IAAI,EAAE,UAAU;AAC1B,UAAU,GAAG,EAAE,IAAI;AACnB,UAAU,SAAS,EAAE,eAAe;AACpC,UAAU,UAAU;AACpB,UAAU,MAAM,EAAE,QAAQ;AAC1B,UAAU,MAAM,EAAE,iBAAiB,CAAC,MAAM;AAC1C,UAAU,MAAM;AAChB,UAAU,OAAO;AACjB,SAAS,CAAC,CAAC;AACX,OAAO;AACP,KAAK;AACL,GAAG;AACH,EAAE,MAAM,IAAI,GAAG;AACf,IAAI,IAAI;AACR,IAAI,OAAO,EAAE,oBAAoB,CAAC,OAAO;AACzC,IAAI,GAAG;AACP,IAAI,MAAM,EAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM;AAC/C,IAAI,KAAK,EAAE,oBAAoB,CAAC,MAAM,EAAE,KAAK;AAC7C,IAAI,MAAM,EAAE,oBAAoB,CAAC,OAAO,EAAE,MAAM;AAChD,IAAI,MAAM;AACV,IAAI,MAAM;AACV,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,IAAI,CAAC;AACd;;;;;;;;"}
@@ -0,0 +1,75 @@
1
+ import { NoticeUserDoc, AbiEvent, AbiError, AbiConstructor, Abi, AbiFunction, ResolvedConfig, UnknownDeployments, Deployment, Artifact } from 'rocketh';
2
+
3
+ type ParamDoc = {
4
+ name: string | `_${number}`;
5
+ description: string;
6
+ };
7
+ type ReturnDoc = {
8
+ name: string | `_${number}`;
9
+ description: string;
10
+ };
11
+ type EventDoc = NoticeUserDoc & {
12
+ readonly name: string;
13
+ readonly signature: string;
14
+ readonly abi: AbiEvent;
15
+ readonly fullFormat: string;
16
+ readonly details?: string;
17
+ readonly params?: ParamDoc[];
18
+ };
19
+ type ErrorDoc = {
20
+ readonly name: string;
21
+ readonly signature: string;
22
+ readonly abi: AbiError;
23
+ readonly fullFormat: string;
24
+ readonly notice?: string[];
25
+ readonly params?: ParamDoc[];
26
+ };
27
+ type NonConstructorMethodDoc = NoticeUserDoc & {
28
+ readonly type: 'function';
29
+ readonly name: string;
30
+ readonly signature: string;
31
+ readonly bytes4: `0x${string}`;
32
+ readonly abi: AbiFunction;
33
+ readonly fullFormat: string;
34
+ readonly details?: string;
35
+ readonly params?: ParamDoc[];
36
+ readonly returns?: ReturnDoc[];
37
+ };
38
+ type ConstructorDoc = NoticeUserDoc & {
39
+ readonly type: 'constructor';
40
+ readonly name: 'constructor';
41
+ readonly signature: string;
42
+ readonly abi: AbiConstructor;
43
+ readonly fullFormat: string;
44
+ readonly details?: string;
45
+ readonly params?: ParamDoc[];
46
+ readonly returns?: ReturnDoc[];
47
+ };
48
+ type MethodDoc = NonConstructorMethodDoc | ConstructorDoc;
49
+ type DocumentationData = {
50
+ readonly name: string;
51
+ readonly abi: Abi;
52
+ readonly events: EventDoc[];
53
+ readonly methods: MethodDoc[];
54
+ readonly errors: ErrorDoc[];
55
+ readonly address?: string;
56
+ readonly title?: string;
57
+ readonly author?: string;
58
+ readonly notice?: string;
59
+ };
60
+
61
+ type RunOptions = {
62
+ template?: string;
63
+ output?: string;
64
+ exceptSuffix?: string[];
65
+ };
66
+ declare function run(config: ResolvedConfig, options: RunOptions): Promise<void>;
67
+ declare function generate({ deployments }: {
68
+ deployments: UnknownDeployments;
69
+ chainId?: string;
70
+ }, options: RunOptions): Promise<void>;
71
+ declare function runFromFolder(folder: string, options: RunOptions): Promise<void>;
72
+ declare function generateFromDeployments(deployments: UnknownDeployments, options: RunOptions): Promise<void>;
73
+ declare function generateDocumentationData(name: string, deploymentOrArfifact: Partial<Deployment<Abi>> & Artifact<Abi>): DocumentationData;
74
+
75
+ export { type ConstructorDoc, type DocumentationData, type ErrorDoc, type EventDoc, type MethodDoc, type ParamDoc, type ReturnDoc, type RunOptions, generate, generateDocumentationData, generateFromDeployments, run, runFromFolder };