Comparing version 0.1.2-beta.3 to 0.1.2-beta.4
@@ -33,3 +33,3 @@ #!/usr/bin/env node | ||
if (cli.flags.output === 'pdf') { | ||
terminalConsole.log('Wait...might take a moment! 🐼️ is doing is stuff...'); | ||
terminalConsole.log('Wait...pdf, might take a moment! 🐼️ is working on it...'); | ||
} | ||
@@ -36,0 +36,0 @@ var ignoreList = []; |
@@ -9,7 +9,6 @@ "use strict"; | ||
var path_1 = __importDefault(require("path")); | ||
var docsify_1 = require("./docsify"); | ||
var gitbook_1 = require("./gitbook"); | ||
var html_1 = require("./html"); | ||
var generate_1 = require("./generate"); | ||
var generate_docsify_1 = require("./generate_docsify"); | ||
var generate_gitbook_1 = require("./generate_gitbook"); | ||
var organize_1 = require("./organize"); | ||
var pdf_1 = require("./pdf"); | ||
var terminalConsole = new console_1.Console(process.stdout, process.stderr); | ||
@@ -23,5 +22,3 @@ /** | ||
var files = []; | ||
// read dir | ||
var filesList = fs_1.default.readdirSync(folder); | ||
// iterate over what was found | ||
filesList.forEach(function (file) { | ||
@@ -32,11 +29,7 @@ if (ignoreFilesList.includes(file)) { | ||
var stats = fs_1.default.lstatSync(path_1.default.join(folder, file)); | ||
// lets see if it is a directory | ||
if (stats.isDirectory()) { | ||
// if so, navigate | ||
var result = deepListFiles(path_1.default.join(folder, file), ignoreFilesList); | ||
// push them all | ||
result.forEach(function (r) { return files.push(r); }); | ||
return; | ||
} | ||
// if not, push file to list, only if it is valid | ||
if (path_1.default.extname(file) === '.sol') { | ||
@@ -56,3 +49,2 @@ files.push(path_1.default.join(folder, file)); | ||
function generate(outputType, ignoreFilesList, outputFolder, inputPath) { | ||
// verify the type of the given input | ||
var stats; | ||
@@ -63,3 +55,2 @@ try { | ||
catch (e) { | ||
// Handle error | ||
terminalConsole.log("The file you are looking for (" + inputPath + ") doesn't exist!"); | ||
@@ -71,13 +62,9 @@ return 1; | ||
if (stats.isDirectory()) { | ||
// if it's a folder, get all files recursively | ||
files = deepListFiles(inputPath, ignoreFilesList); | ||
} | ||
else if (stats.isFile() && !ignoreFilesList.includes(inputPath)) { | ||
// if it's a file, just get the file | ||
files.push(inputPath); | ||
} | ||
// iterate over files to generate HTML | ||
var prepared = []; | ||
files.forEach(function (file) { return prepared.push(organize_1.prepareForFile(file)); }); | ||
// verify if the docs/ folder exist and creates it if not | ||
var destinationDocsFolderPath = path_1.default.join(process.cwd(), outputFolder); | ||
@@ -87,13 +74,14 @@ if (!fs_1.default.existsSync(destinationDocsFolderPath)) { | ||
} | ||
var generateClass = new generate_1.Generate(files, ignoreFilesList, inputPath, outputFolder); | ||
if (outputType === 'pdf') { | ||
pdf_1.generateDocumentation(prepared, outputFolder); | ||
generateClass.pdf(); | ||
} | ||
else if (outputType === 'html') { | ||
html_1.generateDocumentation(prepared, outputFolder); | ||
generateClass.html(); | ||
} | ||
else if (outputType === 'gitbook') { | ||
gitbook_1.generateDocumentation(prepared, outputFolder); | ||
generate_gitbook_1.generateDocumentation(prepared, outputFolder); | ||
} | ||
else if (outputType === 'docsify') { | ||
docsify_1.generateDocumentation(prepared, outputFolder); | ||
generate_docsify_1.generateDocumentation(prepared, outputFolder); | ||
} | ||
@@ -100,0 +88,0 @@ else { |
@@ -20,3 +20,2 @@ "use strict"; | ||
var solidity_parser_antlr_1 = __importDefault(require("solidity-parser-antlr")); | ||
var sol_comments_parser_1 = require("sol-comments-parser"); | ||
function extendParamsAstWithNatspec(node) { | ||
@@ -41,20 +40,10 @@ if (node.parameters === null) { | ||
/** | ||
* Merges the contract ast and comments into an array. | ||
* @param {string} solidityFile the file's path to be parsed | ||
* Prepare for the given file. | ||
* @param {string} solidityFilePath the file's path to be parsed | ||
*/ | ||
function mergeInfoFile(solidityFile) { | ||
// read file | ||
var input = fs_1.default.readFileSync(solidityFile).toString(); | ||
// parse it using solidity-parser-antlr | ||
function prepareForFile(solidityFilePath) { | ||
var folder = path_1.default.join(__dirname, '../'); | ||
var input = fs_1.default.readFileSync(solidityFilePath).toString(); | ||
var ast = solidity_parser_antlr_1.default.parse(input); | ||
// filter for contract definition | ||
var astContract = ast.children.filter(function (child) { return child.type === 'ContractDefinition'; }); | ||
// get filtered comments | ||
var comments = sol_comments_parser_1.mapComments(input); | ||
// get basic information | ||
var rawContractData = { ast: astContract, comments: comments }; | ||
// create an array to save the ast and comments | ||
var contractDataWithComments = { | ||
constructor: null, | ||
contract: undefined, | ||
var data = { | ||
events: [], | ||
@@ -64,5 +53,8 @@ functions: [], | ||
// visit all the methods and add the commands to it | ||
solidity_parser_antlr_1.default.visit(rawContractData.ast, { | ||
solidity_parser_antlr_1.default.visit(ast, { | ||
ContractDefinition: function (node) { | ||
data = __assign({ contract: node }, data); | ||
}, | ||
EventDefinition: function (node) { | ||
contractDataWithComments.events.push({ | ||
data.events.push({ | ||
ast: node, | ||
@@ -75,10 +67,10 @@ parameters: extendParamsAstWithNatspec(node), | ||
if (node.isConstructor) { | ||
contractDataWithComments.constructor = { | ||
ast: node, | ||
parameters: extendParamsAstWithNatspec(node), | ||
returnParameters: extendReturnParamsAstWithNatspec(node), | ||
}; | ||
data = __assign({ constructor: { | ||
ast: node, | ||
parameters: extendParamsAstWithNatspec(node), | ||
returnParameters: extendReturnParamsAstWithNatspec(node), | ||
} }, data); | ||
} | ||
else { | ||
contractDataWithComments.functions.push({ | ||
data.functions.push({ | ||
ast: node, | ||
@@ -91,47 +83,13 @@ parameters: extendParamsAstWithNatspec(node), | ||
}); | ||
// add contract comments | ||
if (rawContractData.comments.contract !== undefined) { | ||
contractDataWithComments.contract = rawContractData | ||
.comments.contract.get(path_1.default.parse(solidityFile).name); | ||
} | ||
// return new info | ||
return [rawContractData.ast[0].name, contractDataWithComments]; | ||
} | ||
/** | ||
* Prepare for the given file. | ||
* @param {string} solidityFilePath the file's path to be parsed | ||
*/ | ||
function prepareForFile(solidityFilePath) { | ||
// get current path folder | ||
var currentFolder = path_1.default.join(__dirname, '../'); | ||
// get ast and comments | ||
var _a = mergeInfoFile(solidityFilePath), contractName = _a[0], contractData = _a[1]; | ||
// get the filename | ||
var name = ast.children.filter(function (child) { return child.type === 'ContractDefinition'; })[0].name; | ||
var filename = path_1.default.parse(solidityFilePath).name; | ||
return { | ||
contractData: contractData, | ||
contractName: contractName, | ||
currentFolder: currentFolder, | ||
data: data, | ||
filename: filename, | ||
solidityFilePath: solidityFilePath, | ||
folder: folder, | ||
name: name, | ||
path: solidityFilePath, | ||
}; | ||
} | ||
exports.prepareForFile = prepareForFile; | ||
function organizeContractsStructure(contractsPreparedData) { | ||
var contractsStructure = []; | ||
contractsPreparedData.forEach(function (contract) { | ||
var contractInfo = {}; | ||
// add name | ||
contractInfo.name = contract.contractName; | ||
contractInfo.filename = contract.filename; | ||
contractInfo.functions = []; | ||
// add functions name | ||
contract.contractData.functions.forEach(function (func) { | ||
contractInfo.functions.push({ name: func.ast.name }); | ||
}); | ||
contractsStructure.push(contractInfo); | ||
}); | ||
return contractsStructure; | ||
} | ||
exports.organizeContractsStructure = organizeContractsStructure; | ||
//# sourceMappingURL=organize.js.map |
{ | ||
"name": "soldoc", | ||
"version": "0.1.2-beta.3", | ||
"version": "0.1.2-beta.4", | ||
"description": "An html page and pdf solidity documentation generator, based in NatSpec format.", | ||
@@ -10,3 +10,4 @@ "main": "dist/index.js", | ||
"files": [ | ||
"/dist" | ||
"/dist/**/*.js", | ||
"/dist/**/*.html" | ||
], | ||
@@ -21,6 +22,8 @@ "scripts": { | ||
"test": "jest --testTimeout=40000", | ||
"build:watch": "tsc -w && cp -r src/template dist && chmod u+x dist/cli.js", | ||
"test:watch": "jest --testTimeout=40000 --watchAll", | ||
"coverage": "jest --coverage --testTimeout=40000", | ||
"precoverage:ci": "yarn build", | ||
"coverage:ci": "jest --coverage --testTimeout=40000 --detectOpenHandles --forceExit && cat ./coverage/lcov.info | coveralls", | ||
"docs": "jsdoc ./src/*.js -d ./docs" | ||
"docs": "typedoc --out docs src" | ||
}, | ||
@@ -52,30 +55,38 @@ "repository": { | ||
"homepage": "https://github.com/hq20/soldoc#readme", | ||
"peerDependencies": { | ||
"highlight.js": "9.17.x", | ||
"markdown-it": "10.0.x", | ||
"markdown-it-emoji": "1.4.x", | ||
"meow": "6.0.x", | ||
"mustache": "3.1.x", | ||
"node-emoji": "1.10.x", | ||
"pdf-from-html": "0.1.x" | ||
}, | ||
"dependencies": { | ||
"@types/highlight.js": "9.12.3", | ||
"@types/meow": "5.0.0", | ||
"@types/mustache": "0.8.32", | ||
"@types/node": "12.12.14", | ||
"@types/node-emoji": "1.8.1", | ||
"highlight.js": "9.16.2", | ||
"solidity-parser-antlr": "git://github.com/obernardovieira/solidity-parser-antlr.git#5fb4ceb" | ||
}, | ||
"devDependencies": { | ||
"highlight.js": "9.17.1", | ||
"markdown-it": "10.0.0", | ||
"markdown-it-emoji": "1.4.0", | ||
"meow": "5.0.0", | ||
"meow": "6.0.0", | ||
"mustache": "3.1.0", | ||
"node-emoji": "1.10.0", | ||
"pdf-from-html": "0.1.1", | ||
"sol-comments-parser": "0.1.2-beta.0", | ||
"solidity-parser-antlr": "git://github.com/obernardovieira/solidity-parser-antlr.git#5fb4ceb", | ||
"typescript": "3.7.3" | ||
}, | ||
"devDependencies": { | ||
"@types/highlight.js": "9.12.3", | ||
"@types/meow": "5.0.0", | ||
"@types/mustache": "0.8.32", | ||
"@types/node": "12.12.18", | ||
"@types/node-emoji": "1.8.1", | ||
"typescript": "3.7.3", | ||
"@types/jest": "24.0.23", | ||
"coveralls": "3.0.9", | ||
"directory-tree": "2.2.4", | ||
"expect.js": "0.3.1", | ||
"jest": "24.9.0", | ||
"jest-puppeteer": "4.3.0", | ||
"jsdoc": "3.6.3", | ||
"pdf-to-text": "0.0.7", | ||
"puppeteer": "1.20.0", | ||
"puppeteer": "2.0.0", | ||
"tslint": "5.20.1", | ||
"typedoc": "0.15.3", | ||
"typedoc": "0.15.5", | ||
"typescript-tslint-plugin": "0.5.5" | ||
@@ -82,0 +93,0 @@ }, |
@@ -8,8 +8,9 @@ <p align="center"> | ||
[![Coverage Status](https://coveralls.io/repos/github/HQ20/soldoc/badge.svg?branch=master)](https://coveralls.io/github/HQ20/soldoc?branch=master) | ||
[![Netlify Status](https://api.netlify.com/api/v1/badges/084d2d9e-5f67-46c8-a8e7-22d73f2f707d/deploy-status)](https://app.netlify.com/sites/soldoc-demo/deploys) | ||
soldoc is a solidity documentation generator. This generator was created due to a need of giving documentation to developers and clients. Thinking about it, we first created this tool to generate an HTML self hosted page, but then we also decided to generate a PDF. | ||
> soldoc is a solidity documentation generator. This generator was created due to a need of giving documentation to developers and clients. Thinking about it, we first created this tool to generate an HTML self hosted page, but then we also decided to generate a PDF. | ||
See demo [here](https://soldoc-demo.netlify.com/). | ||
Please note that, there's also a pdf example in `./example` folder. This pdf is a first draft. We intend to have a better template soon and open the opportunity to get new templates. | ||
Please note that, there's also a pdf example in `./example` folder. This pdf is a first draft. We intend to have a better template and open the opportunity to get new templates. | ||
@@ -49,3 +50,3 @@ ## Features | ||
generate(toPdf: boolean, outputFolder: string, filePathInput: string) | ||
generate(outputType: string, ignoreFilesList: string[], outputFolder: string, inputPath: string) | ||
``` | ||
@@ -63,17 +64,7 @@ | ||
### Logo | ||
The sun | ||
* https://www.iconfinder.com/icons/2995005/giallo_sole_soleggiato_sun_sunny_weather_yellow_icon | ||
* https://creativecommons.org/licenses/by/3.0/ | ||
The [sun](https://www.iconfinder.com/icons/2995005/giallo_sole_soleggiato_sun_sunny_weather_yellow_icon), the [A Directory Tree List Style A PEN BY Alex Raven](https://codepen.io/asraven/pen/qbrQMX), the [Font Family](https://www.dafont.com/pt/subscriber.font). As well as [Connor](https://github.com/connorltodd), who drafted the initial HTML template, and [zlocate](https://github.com/zlocate) | ||
### Font Family | ||
* https://www.dafont.com/pt/subscriber.font | ||
Thank you. Danke. Merci. Grazie. Gracias. Arigato. Obrigado. | ||
## Thanks to | ||
* [Connor](https://github.com/connorltodd), who drafted the initial HTML template. | ||
* [zlocate](https://github.com/zlocate) | ||
## License | ||
[GPL-3.0](LICENSE) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8
6
92237
24
13
559
68
1
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@types/minimist@1.2.5(transitive)
+ Added@types/node@22.10.1(transitive)
+ Added@types/normalize-package-data@2.4.4(transitive)
+ Added@types/yauzl@2.10.3(transitive)
+ Addedagent-base@5.1.1(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@4.1.0(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedcamelcase-keys@6.2.2(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedextract-zip@2.0.1(transitive)
+ Addedfind-up@4.1.0(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedhandlebars@4.7.8(transitive)
+ Addedhard-rejection@2.1.0(transitive)
+ Addedhighlight.js@9.17.1(transitive)
+ Addedhttps-proxy-agent@4.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedindent-string@4.0.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjson-parse-even-better-errors@2.3.1(transitive)
+ Addedlines-and-columns@1.2.4(transitive)
+ Addedlocate-path@5.0.0(transitive)
+ Addedmap-obj@4.3.0(transitive)
+ Addedmeow@6.0.17.1.1(transitive)
+ Addedmin-indent@1.0.1(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addedmustache@4.2.0(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@4.1.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedparse-json@5.2.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpdf-from-html@0.1.2(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedpuppeteer@3.3.0(transitive)
+ Addedquick-lru@4.0.1(transitive)
+ Addedread-pkg@5.2.0(transitive)
+ Addedread-pkg-up@7.0.1(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedredent@3.0.0(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedstrip-indent@3.0.0(transitive)
+ Addedtar-fs@2.1.1(transitive)
+ Addedtar-stream@2.2.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtrim-newlines@3.0.1(transitive)
+ Addedtype-fest@0.13.10.6.00.8.1(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedunbzip2-stream@1.4.3(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedwordwrap@1.0.0(transitive)
+ Addedws@7.5.10(transitive)
+ Addedyargs-parser@16.1.018.1.3(transitive)
- Removed@types/highlight.js@9.12.3
- Removed@types/meow@5.0.0
- Removed@types/mustache@0.8.32
- Removed@types/node@12.12.14
- Removed@types/node-emoji@1.8.1
- Removedhighlight.js@9.16.2
- Removedmarkdown-it@10.0.0
- Removedmarkdown-it-emoji@1.4.0
- Removedmeow@5.0.0
- Removedmustache@3.1.0
- Removednode-emoji@1.10.0
- Removedpdf-from-html@0.1.1
- Removedsol-comments-parser@0.1.2-beta.0
- Removedtypescript@3.7.3
- Removed@types/highlight.js@9.12.3(transitive)
- Removed@types/meow@5.0.0(transitive)
- Removed@types/minimist-options@4.0.1(transitive)
- Removed@types/mustache@0.8.32(transitive)
- Removed@types/node@12.12.14(transitive)
- Removed@types/node-emoji@1.8.1(transitive)
- Removedagent-base@4.3.0(transitive)
- Removedarray-find-index@1.0.2(transitive)
- Removedasync-limiter@1.0.1(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedcamelcase@4.1.0(transitive)
- Removedcamelcase-keys@4.2.0(transitive)
- Removedconcat-stream@1.6.2(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedcurrently-unhandled@0.4.1(transitive)
- Removeddebug@2.6.93.2.7(transitive)
- Removedes6-promise@4.2.8(transitive)
- Removedes6-promisify@5.0.0(transitive)
- Removedextract-zip@1.7.0(transitive)
- Removedfind-up@2.1.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhighlight.js@9.16.2(transitive)
- Removedhttps-proxy-agent@2.2.4(transitive)
- Removedindent-string@3.2.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedload-json-file@4.0.0(transitive)
- Removedlocate-path@2.0.0(transitive)
- Removedloud-rejection@1.6.0(transitive)
- Removedmap-obj@2.0.0(transitive)
- Removedmeow@5.0.0(transitive)
- Removedminimist-options@3.0.2(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.0.0(transitive)
- Removedmustache@3.0.1(transitive)
- Removedp-limit@1.3.0(transitive)
- Removedp-locate@2.0.0(transitive)
- Removedp-try@1.0.0(transitive)
- Removedparse-json@4.0.0(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedpath-type@3.0.0(transitive)
- Removedpdf-from-html@0.1.1(transitive)
- Removedpify@3.0.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedpuppeteer@1.19.0(transitive)
- Removedquick-lru@1.1.0(transitive)
- Removedread-pkg@3.0.0(transitive)
- Removedread-pkg-up@3.0.0(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedredent@2.0.0(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedsol-comments-parser@0.1.2-beta.0(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removedstrip-indent@2.0.0(transitive)
- Removedtrim-newlines@2.0.0(transitive)
- Removedtypedarray@0.0.6(transitive)
- Removedtypescript@3.7.3(transitive)
- Removedws@6.2.3(transitive)
- Removedyargs-parser@10.1.0(transitive)