Simple utility to transform your TS code to MermaidJS syntax for flowcharts.
New file *.mmd is generated next to each TS file which fulfilled condition.
Install utility as dev dependency: npm install --dev @stechy1/ast-to-mmd
.
Run it with npx @stechy1/ast-to-mmd
.
source code
function fun() {
foo();
for (let i = 0; i < 10; i++) {
bar();
baz();
}
fooBar();
}
transformed to mmd syntax
flowchart TD
subgraph 600 ["Functions"]
direction TB
subgraph 580 ["fun"]
direction TB
581[["foo()"]]
subgraph 595_16 ["CYCLE_16"]
direction TB
595[/"i = 0; i < 10; i++"/]
582[["bar()"]]
583[["baz()"]]
595 ---> 582
583 -. "loop_16" .-> 595
582 ---> 583
end
596[["fooBar()"]]
581 ---> 595
583 ---> 596
end
end
subgraph 601 ["Classes"]
direction TB
end
rendered result
Supported logical condition constructs:
Example of simmple JSON conditions:
{
"and": [
{
"endsWith": "handler.ts",
"contains": "event",
"not": {
"contains": "entity"
}
}
]
}