Skip to content

Commit

Permalink
feat: display function modifiers in class diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
naddison36 committed Sep 2, 2022
1 parent 2d17d84 commit 34f7267
Show file tree
Hide file tree
Showing 10 changed files with 743 additions and 750 deletions.
1,472 changes: 724 additions & 748 deletions examples/polygonMusd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/converterAST2Classes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/converterClass2Dot.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/umlClass.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface Operator extends Attribute {
parameters?: Parameter[];
returnParameters?: Parameter[];
isPayable?: boolean;
modifiers?: string[];
}
export declare enum ReferenceType {
Memory = 0,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sol2uml",
"version": "2.1.9",
"version": "2.2.0",
"description": "Solidity contract visualisation tool.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions src/contracts/SomeImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ contract SomeImpl is SomeInterface {
_;
}

function withModifier() someModifier(true) {
}

function withTwoModifiers(uint256 someInt) someModifier(true) modifierMultiParams(false, someInt) {
}

function add(uint256 someNumber) public returns (uint256) {
somePublicNumber = somePublicNumber + someNumber;
return somePublicNumber;
Expand Down
1 change: 1 addition & 0 deletions src/ts/converterAST2Classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ function parseContractDefinition(
stereotype,
parameters: parseParameters(subNode.parameters),
returnParameters: parseParameters(subNode.returnParameters),
modifiers: subNode.modifiers.map((m) => m.name),
})
}

Expand Down
4 changes: 4 additions & 0 deletions src/ts/converterClass2Dot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ const dotOperators = (
dotString += ': ' + dotParameters(operator.returnParameters, true)
}

if (options.hideModifiers === false && operator.modifiers?.length > 0) {
dotString += ` \\<\\<${operator.modifiers.join(', ')}\\>\\>`
}

dotString += '\\l'
}

Expand Down
1 change: 1 addition & 0 deletions src/ts/umlClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface Operator extends Attribute {
parameters?: Parameter[]
returnParameters?: Parameter[]
isPayable?: boolean
modifiers?: string[]
}

export enum ReferenceType {
Expand Down

0 comments on commit 34f7267

Please sign in to comment.