Comparing version 1.1.21 to 1.1.22
@@ -7,3 +7,3 @@ import { ClassOptions } from './dotGenerator'; | ||
export declare function convertUmlClasses2Dot(umlClasses: UmlClass[], clusterFolders?: boolean, classOptions?: ClassOptions): string; | ||
export declare function addAssociationsToDot(umlClasses: UmlClass[]): string; | ||
export declare function addAssociationsToDot(umlClasses: UmlClass[], classOptions?: ClassOptions): string; | ||
export declare function convertDot2Svg(dot: string): any; | ||
@@ -10,0 +10,0 @@ export declare function writeDot(dot: string, dotFilename?: string): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.writePng = exports.writeSVG = exports.writeDot = exports.convertDot2Svg = exports.addAssociationsToDot = exports.convertUmlClasses2Dot = exports.convertUmlClassesToSvg = exports.generateFilesFromUmlClasses = void 0; | ||
const dotGenerator_1 = require("./dotGenerator"); | ||
const debug = require('debug')('sol2uml'); | ||
const fs_1 = require("fs"); | ||
const umlClass_1 = require("./umlClass"); | ||
const path = require('path'); | ||
const svg_to_png = require('svg-to-png'); | ||
const verror_1 = require("verror"); | ||
const path = require('path'); | ||
const Viz = require('viz.js'); | ||
const svg_to_png = require('svg-to-png'); | ||
const dotGenerator_1 = require("./dotGenerator"); | ||
const umlClass_1 = require("./umlClass"); | ||
const debug = require('debug')('sol2uml'); | ||
const generateFilesFromUmlClasses = async (umlClasses, outputBaseName, outputFormat = 'svg', outputFilename, clusterFolders = false, classOptions = {}) => { | ||
@@ -76,3 +76,3 @@ const dot = convertUmlClasses2Dot(umlClasses, clusterFolders, classOptions); | ||
} | ||
dotString += addAssociationsToDot(umlClasses); | ||
dotString += addAssociationsToDot(umlClasses, classOptions); | ||
// Need to close off the last the digraph | ||
@@ -102,3 +102,3 @@ dotString += '\n}'; | ||
} | ||
function addAssociationsToDot(umlClasses) { | ||
function addAssociationsToDot(umlClasses, classOptions = {}) { | ||
let dotString = ''; | ||
@@ -118,3 +118,3 @@ // for each class | ||
if (targetUmlClass) { | ||
dotString += addAssociationToDot(sourceUmlClass, targetUmlClass, association); | ||
dotString += addAssociationToDot(sourceUmlClass, targetUmlClass, association, classOptions); | ||
} | ||
@@ -126,3 +126,10 @@ } | ||
exports.addAssociationsToDot = addAssociationsToDot; | ||
function addAssociationToDot(sourceUmlClass, targetUmlClass, association) { | ||
function addAssociationToDot(sourceUmlClass, targetUmlClass, association, classOptions = {}) { | ||
// do not include library or interface associations if hidden | ||
if ((classOptions.hideLibraries && | ||
targetUmlClass.stereotype === umlClass_1.ClassStereotype.Library) || | ||
(classOptions.hideInterfaces && | ||
targetUmlClass.stereotype === umlClass_1.ClassStereotype.Interface)) { | ||
return ''; | ||
} | ||
let dotString = `\n${sourceUmlClass.id} -> ${targetUmlClass.id} [`; | ||
@@ -129,0 +136,0 @@ if (association.referenceType == umlClass_1.ReferenceType.Memory || |
@@ -7,3 +7,5 @@ import { UmlClass } from './umlClass'; | ||
hideEnums?: boolean; | ||
hideLibraries?: boolean; | ||
hideInterfaces?: boolean; | ||
} | ||
export declare const dotUmlClass: (umlClass: UmlClass, options?: ClassOptions) => string; |
@@ -7,2 +7,9 @@ "use strict"; | ||
const dotUmlClass = (umlClass, options = {}) => { | ||
// do not include library or interface classes if hidden | ||
if ((options.hideLibraries && | ||
umlClass.stereotype === umlClass_1.ClassStereotype.Library) || | ||
(options.hideInterfaces && | ||
umlClass.stereotype === umlClass_1.ClassStereotype.Interface)) { | ||
return ''; | ||
} | ||
let dotString = `\n${umlClass.id} [label="{${dotClassTitle(umlClass)}`; | ||
@@ -9,0 +16,0 @@ // Add attributes |
@@ -1,2 +0,2 @@ | ||
import { ASTNode } from '@solidity-parser/parser'; | ||
import { ASTNode } from '@solidity-parser/parser/dist/ast-types'; | ||
import { UmlClass } from './umlClass'; | ||
@@ -3,0 +3,0 @@ declare const networks: readonly ["mainnet", "ropsten", "kovan", "rinkeby", "goerli"]; |
@@ -1,2 +0,2 @@ | ||
import { ASTNode } from '@solidity-parser/parser'; | ||
import { ASTNode } from '@solidity-parser/parser/dist/ast-types'; | ||
import { UmlClass } from './umlClass'; | ||
@@ -3,0 +3,0 @@ export declare const parseUmlClassesFromFiles: (filesOrFolders: string[], ignoreFilesOrFolders: string[], depthLimit?: number) => Promise<UmlClass[]>; |
@@ -1,3 +0,3 @@ | ||
import { ASTNode } from '@solidity-parser/parser'; | ||
import { ASTNode } from '@solidity-parser/parser/dist/ast-types'; | ||
import { UmlClass } from './umlClass'; | ||
export declare function convertNodeToUmlClass(node: ASTNode, codePath: string): UmlClass[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertNodeToUmlClass = void 0; | ||
const path_1 = require("path"); | ||
const umlClass_1 = require("./umlClass"); | ||
const path_1 = require("path"); | ||
const debug = require('debug')('sol2uml'); | ||
@@ -123,9 +123,6 @@ function convertNodeToUmlClass(node, codePath) { | ||
name: subNode.name, | ||
// @ts-ignore ModifierDefinition type missing parameters | ||
parameters: parseParameters(subNode.parameters), | ||
}); | ||
// @ts-ignore ModifierDefinition type is missing body | ||
if (subNode.body && subNode.body.statements) { | ||
// Recursively parse modifier statements for associations | ||
// @ts-ignore ModifierDefinition type is missing body | ||
umlClass = addAssociations(subNode.body.statements, umlClass); | ||
@@ -168,2 +165,3 @@ } | ||
function addAssociations(nodes, umlClass) { | ||
var _a, _b, _c, _d; | ||
if (!nodes || !Array.isArray(nodes)) { | ||
@@ -235,14 +233,26 @@ debug('Warning - can not recursively parse AST nodes for associations. Invalid nodes array'); | ||
case 'IfStatement': | ||
// @ts-ignore type Statement can be a Block | ||
if (node.trueBody && node.trueBody.statements) { | ||
// @ts-ignore type ExpressionStatement can contain statements in a Block | ||
if ((_a = node.trueBody) === null || _a === void 0 ? void 0 : _a.statements) { | ||
umlClass = addAssociations( | ||
// @ts-ignore | ||
// @ts-ignore type ExpressionStatement can contain statements in a Block | ||
node.trueBody.statements, umlClass); | ||
} | ||
// @ts-ignore type Statement can be a Block | ||
if (node.falseBody && node.falseBody.statements) { | ||
// @ts-ignore type ExpressionStatement can contain an expression | ||
if ((_b = node.trueBody) === null || _b === void 0 ? void 0 : _b.expression) { | ||
umlClass = parseExpression( | ||
// @ts-ignore type ExpressionStatement can contain an expression | ||
node.trueBody.expression, umlClass); | ||
} | ||
// @ts-ignore type ExpressionStatement can contain statements in a Block | ||
if ((_c = node.falseBody) === null || _c === void 0 ? void 0 : _c.statements) { | ||
umlClass = addAssociations( | ||
// @ts-ignore | ||
// @ts-ignore type ExpressionStatement can contain statements in a Block | ||
node.falseBody.statements, umlClass); | ||
} | ||
// @ts-ignore type ExpressionStatement can contain an expression | ||
if ((_d = node.falseBody) === null || _d === void 0 ? void 0 : _d.expression) { | ||
umlClass = parseExpression( | ||
// @ts-ignore type ExpressionStatement can contain an expression | ||
node.falseBody.expression, umlClass); | ||
} | ||
umlClass = parseExpression(node.condition, umlClass); | ||
@@ -292,10 +302,7 @@ break; | ||
} | ||
// @ts-ignore | ||
else if (expression.type === 'NewExpression') { | ||
// @ts-ignore | ||
umlClass = addAssociations([expression.typeName], umlClass); | ||
} | ||
// @ts-ignore IDEX 0x2a0c0DBEcC7E4D658f48E01e3fA353F44050c208 has this | ||
else if (expression.type === 'UnaryOperation' && expression.subExpression) { | ||
// @ts-ignore | ||
else if (expression.type === 'UnaryOperation' && | ||
expression.subExpression) { | ||
umlClass = parseExpression(expression.subExpression, umlClass); | ||
@@ -302,0 +309,0 @@ } |
@@ -32,2 +32,4 @@ #! /usr/bin/env node | ||
.option('-s, --hideStructs ', 'hide data structures') | ||
.option('-l, --hideLibraries ', 'hide libraries') | ||
.option('-t, --hideInterfaces ', 'hide interfaces') | ||
.option('-k, --etherscanApiKey <key>', 'Etherscan API Key') | ||
@@ -79,2 +81,4 @@ .option('-c, --clusterFolders', 'cluster contracts into source folders') | ||
hideStructs: program.hideStructs, | ||
hideLibraries: program.hideLibraries, | ||
hideInterfaces: program.hideInterfaces, | ||
}).then(() => { | ||
@@ -81,0 +85,0 @@ debug(`Finished`); |
{ | ||
"name": "sol2uml", | ||
"version": "1.1.21", | ||
"version": "1.1.22", | ||
"description": "Unified Modeling Language (UML) class diagram generator for Solidity contracts", | ||
@@ -27,3 +27,3 @@ "main": "./lib/index.js", | ||
"klaw": "^3.0.0", | ||
"@solidity-parser/parser": "^0.9.1", | ||
"@solidity-parser/parser": "^0.10.1", | ||
"svg-to-png": "^4.0.0", | ||
@@ -34,3 +34,3 @@ "verror": "^1.10.0", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.16", | ||
"@types/jest": "^26.0.19", | ||
"@types/klaw": "^3.0.1", | ||
@@ -42,3 +42,3 @@ "@types/verror": "^1.10.4", | ||
"ts-jest": "^26.4.4", | ||
"typescript": "^4.1.2" | ||
"typescript": "^4.1.3" | ||
}, | ||
@@ -45,0 +45,0 @@ "files": [ |
@@ -60,2 +60,4 @@ # Solidity 2 UML | ||
-s, --hideStructs hide data structures | ||
-l, --hideLibraries hide libraries | ||
-t, --hideInterfaces hide interfaces | ||
-k, --etherscanApiKey <key> Etherscan API Key | ||
@@ -188,3 +190,3 @@ -c, --clusterFolders cluster contracts into source folders | ||
This version uses the [solidity-parser-antlr](https://github.com/ConsenSys/solidity-parser-antlr) Solidity parser. This is a ConsenSys fork of Federico Bond's (GitHub @federicobond) [solidity-parser-antlr](https://github.com/federicobond/solidity-parser-antlr) parser which was built on top of [ANTLR4 grammar](https://github.com/solidityj/solidity-antlr4). The logic to generate the dot syntax has been rewritten and different UML syntax is now used to Richard Ramos's original implementation. | ||
sol2uml uses [@solidity-parser/parser](https://github.com/solidity-parser/parser) which is maintained by the Solidity tool community lead by Franco Victorio (@fvictorio). This is a fork of Federico Bond's (GitHub @federicobond) [solidity-parser-antlr](https://github.com/federicobond/solidity-parser-antlr). The logic to generate the dot syntax has been rewritten and different UML syntax is now used to Richard Ramos's original implementation. | ||
@@ -191,0 +193,0 @@ The [Solidity language grammar](https://solidity.readthedocs.io/en/develop/miscellaneous.html#language-grammar) is published with each major release. |
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
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
70633
1392
194
+ Added@solidity-parser/parser@0.10.2(transitive)
- Removed@solidity-parser/parser@0.9.1(transitive)
- Removedantlr4@4.13.2(transitive)