@likec4/generators 0.49.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/src/mmd/generate-mmd.ts +34 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/generators",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
6
6
|
"homepage": "https://likec4.dev",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"test": "run -T vitest run"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@likec4/core": "0.
|
|
37
|
+
"@likec4/core": "0.51.0",
|
|
38
38
|
"json5": "^2.2.3",
|
|
39
|
-
"langium": "^2.1.
|
|
39
|
+
"langium": "^2.1.3",
|
|
40
40
|
"rambdax": "^9.1.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^20.
|
|
44
|
-
"typescript": "^5.
|
|
43
|
+
"@types/node": "^20.10.3",
|
|
44
|
+
"typescript": "^5.3.2",
|
|
45
45
|
"unbuild": "^2.0.0",
|
|
46
|
-
"vitest": "^0.
|
|
46
|
+
"vitest": "^1.0.1"
|
|
47
47
|
},
|
|
48
48
|
"packageManager": "yarn@4.0.2",
|
|
49
49
|
"volta": {
|
package/src/mmd/generate-mmd.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComputedEdge, ComputedNode, ComputedView, NodeId } from '@likec4/core'
|
|
2
|
-
import { CompositeGeneratorNode, NL, joinToNode, toString } from 'langium'
|
|
2
|
+
import { CompositeGeneratorNode, NL, NLEmpty, expandToNode, joinToNode, toString } from 'langium'
|
|
3
3
|
import { isNil } from 'rambdax'
|
|
4
4
|
|
|
5
5
|
const capitalizeFirstLetter = (value: string) =>
|
|
@@ -46,20 +46,20 @@ export function generateMermaid<V extends ComputedView>(view: V) {
|
|
|
46
46
|
baseNode
|
|
47
47
|
.append('subgraph ', fqnName, '["', label, '"]', NL)
|
|
48
48
|
.indent({
|
|
49
|
-
indentedChildren:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
indentedChildren: [
|
|
50
|
+
joinToNode(
|
|
51
|
+
nodes.filter(n => n.parent === node.id),
|
|
52
|
+
n => printNode(n, fqnName),
|
|
53
|
+
{
|
|
54
|
+
appendNewLineIfNotEmpty: true
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
],
|
|
58
58
|
indentation: 2
|
|
59
59
|
})
|
|
60
60
|
.append('end', NL)
|
|
61
61
|
} else {
|
|
62
|
-
baseNode.append(fqnName, shape[0], label, shape[1]
|
|
62
|
+
baseNode.append(fqnName, shape[0], label, shape[1])
|
|
63
63
|
}
|
|
64
64
|
return baseNode
|
|
65
65
|
}
|
|
@@ -80,27 +80,32 @@ export function generateMermaid<V extends ComputedView>(view: V) {
|
|
|
80
80
|
view.title !== null && view.title.length > 0,
|
|
81
81
|
'---',
|
|
82
82
|
NL,
|
|
83
|
-
`title: ${view.title}`,
|
|
83
|
+
`title: ${JSON.stringify(view.title)}`,
|
|
84
84
|
NL,
|
|
85
85
|
'---',
|
|
86
86
|
NL
|
|
87
87
|
)
|
|
88
|
-
.append('graph ', view.autoLayout, NL
|
|
89
|
-
.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
88
|
+
.append('graph ', view.autoLayout, NL)
|
|
89
|
+
.indent({
|
|
90
|
+
indentedChildren: indent => {
|
|
91
|
+
indent
|
|
92
|
+
.append(
|
|
93
|
+
joinToNode(
|
|
94
|
+
nodes.filter(n => isNil(n.parent)),
|
|
95
|
+
n => printNode(n),
|
|
96
|
+
{
|
|
97
|
+
appendNewLineIfNotEmpty: true
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
.appendIf(
|
|
102
|
+
edges.length > 0,
|
|
103
|
+
joinToNode(edges, e => printEdge(e), {
|
|
104
|
+
appendNewLineIfNotEmpty: true
|
|
105
|
+
})
|
|
106
|
+
)
|
|
107
|
+
},
|
|
108
|
+
indentation: 2
|
|
109
|
+
})
|
|
105
110
|
)
|
|
106
111
|
}
|