Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

soldoc

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

soldoc - npm Package Compare versions

Comparing version 0.1.2-beta.3 to 0.1.2-beta.4

dist/generate_docsify.js

2

dist/cli.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc