aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-doc/src
diff options
context:
space:
mode:
authorF. Eugene Aumson <gene@aumson.org>2018-09-22 22:31:47 +0800
committerF. Eugene Aumson <gene@aumson.org>2018-09-22 22:55:46 +0800
commit9f0dfb1e1a4c97e462cf298e0452be1d0fcf2216 (patch)
tree0a4e7c5164c4c6f023988203f81d1fabe7e022a5 /packages/sol-doc/src
parent37cb18e1daa8bf33b92b94b93851e91d50383c1e (diff)
downloaddexon-sol-tools-9f0dfb1e1a4c97e462cf298e0452be1d0fcf2216.tar
dexon-sol-tools-9f0dfb1e1a4c97e462cf298e0452be1d0fcf2216.tar.gz
dexon-sol-tools-9f0dfb1e1a4c97e462cf298e0452be1d0fcf2216.tar.bz2
dexon-sol-tools-9f0dfb1e1a4c97e462cf298e0452be1d0fcf2216.tar.lz
dexon-sol-tools-9f0dfb1e1a4c97e462cf298e0452be1d0fcf2216.tar.xz
dexon-sol-tools-9f0dfb1e1a4c97e462cf298e0452be1d0fcf2216.tar.zst
dexon-sol-tools-9f0dfb1e1a4c97e462cf298e0452be1d0fcf2216.zip
feat: make sol-doc only document what's requested
if a list of contracts-to-document is passed into sol-doc, then the output should only contain documentation for the contracts requested. if an empty/undefined list is passed, then it should document all contracts that were found.
Diffstat (limited to 'packages/sol-doc/src')
-rw-r--r--packages/sol-doc/src/solidity_doc_generator.ts21
1 files changed, 18 insertions, 3 deletions
diff --git a/packages/sol-doc/src/solidity_doc_generator.ts b/packages/sol-doc/src/solidity_doc_generator.ts
index 2586cf91c..074fb1f37 100644
--- a/packages/sol-doc/src/solidity_doc_generator.ts
+++ b/packages/sol-doc/src/solidity_doc_generator.ts
@@ -1,3 +1,5 @@
+import * as path from 'path';
+
import * as _ from 'lodash';
import {
@@ -34,8 +36,7 @@ export async function generateSolDocAsync(
contractsDir: string,
contractsToDocument?: string[],
): Promise<DocAgnosticFormat> {
- const doc: DocAgnosticFormat = {};
-
+ const docWithDependencies: DocAgnosticFormat = {};
const compilerOptions = _makeCompilerOptions(contractsDir, contractsToDocument);
const compiler = new Compiler(compilerOptions);
const compilerOutputs = await compiler.getCompilerOutputsAsync();
@@ -50,11 +51,25 @@ export async function generateSolDocAsync(
if (_.isUndefined(compiledContract.abi)) {
throw new Error('compiled contract did not contain ABI output');
}
- doc[contractName] = _genDocSection(compiledContract);
+ docWithDependencies[contractName] = _genDocSection(compiledContract);
}
}
}
+ let doc: DocAgnosticFormat = {};
+ if (_.isUndefined(contractsToDocument) || contractsToDocument.length === 0) {
+ doc = docWithDependencies;
+ } else {
+ for (const contractToDocument of contractsToDocument) {
+ const contractBasename = path.basename(contractToDocument);
+ const contractName =
+ contractBasename.lastIndexOf('.sol') === -1
+ ? contractBasename
+ : contractBasename.substring(0, contractBasename.lastIndexOf('.sol'));
+ doc[contractName] = docWithDependencies[contractName];
+ }
+ }
+
return doc;
}