Skip to content

Commit 8c40eb3

Browse files
committed
Merge branch next into add-sankey-langium-parser
2 parents b6906a6 + 91eb824 commit 8c40eb3

File tree

151 files changed

+5460
-4452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+5460
-4452
lines changed

CONTRIBUTING.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ Documentation is necessary for all non bugfix/refactoring changes.
7171

7272
Only make changes to files that are in [`/packages/mermaid/src/docs`](packages/mermaid/src/docs)
7373

74-
**_DO NOT CHANGE FILES IN `/docs`_**
74+
**_DO NOT CHANGE FILES IN `/docs` MANUALLY_**
75+
76+
The `/docs` folder will be rebuilt and committed as part of a pre-commit hook.
7577

7678
[Join our slack community if you want closer contact!](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)

README.md

+2-14
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,7 @@ class Class10 {
165165
int id
166166
size()
167167
}
168-
namespace Namespace01 {
169-
class Class11
170-
class Class12 {
171-
int id
172-
size()
173-
}
174-
}
168+
175169
```
176170

177171
```mermaid
@@ -191,13 +185,7 @@ class Class10 {
191185
int id
192186
size()
193187
}
194-
namespace Namespace01 {
195-
class Class11
196-
class Class12 {
197-
int id
198-
size()
199-
}
200-
}
188+
201189
```
202190

203191
### State diagram [<a href="https://mermaid-js.github.io/mermaid/#/stateDiagram">docs</a> - <a href="https://mermaid.live/edit#pako:eNpdkEFvgzAMhf8K8nEqpYSNthx22Xbcqcexg0sCiZQQlDhIFeK_L8A6TfXp6fOz9ewJGssFVOAJSbwr7ByadGR1n8T6evpO0vQ1uZDSekOrXGFsPqJPO6q-2-imH8f_0TeHXm50lfelsAMjnEHFY6xpMdRAUhhRQxUlFy0GTTXU_RytYeAx-AdXZB1ULWovdoCB7OXWN1CRC-Ju-r3uz6UtchGHJqDbsPygU57iysb2reoWHpyOWBINvsqypb3vFMlw3TfWZF5xiY7keC6zkpUnZIUojwW-FAVvrvn51LLnvOXHQ84Q5nn-AVtLcwk">live editor</a>]

cSpell.json

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"brkt",
2323
"brolin",
2424
"brotli",
25+
"catmull",
2526
"città",
2627
"classdef",
2728
"codedoc",
@@ -38,7 +39,10 @@
3839
"docsy",
3940
"doku",
4041
"dompurify",
42+
"dont",
43+
"doublecircle",
4144
"edgechromium",
45+
"elems",
4246
"elkjs",
4347
"elle",
4448
"faber",

cypress/helpers/util.ts

+16-25
Original file line numberDiff line numberDiff line change
@@ -52,41 +52,32 @@ export const imgSnapshotTest = (
5252
api = false,
5353
validation?: any
5454
): void => {
55-
cy.log(JSON.stringify(_options));
56-
const options: CypressMermaidConfig = Object.assign(_options);
57-
if (!options.fontFamily) {
58-
options.fontFamily = 'courier';
59-
}
60-
if (!options.sequence) {
61-
options.sequence = {};
62-
}
63-
if (!options.sequence || (options.sequence && !options.sequence.actorFontFamily)) {
64-
options.sequence.actorFontFamily = 'courier';
65-
}
66-
if (options.sequence && !options.sequence.noteFontFamily) {
67-
options.sequence.noteFontFamily = 'courier';
68-
}
69-
options.sequence.actorFontFamily = 'courier';
70-
options.sequence.noteFontFamily = 'courier';
71-
options.sequence.messageFontFamily = 'courier';
72-
if (options.sequence && !options.sequence.actorFontFamily) {
73-
options.sequence.actorFontFamily = 'courier';
74-
}
75-
if (!options.fontSize) {
76-
options.fontSize = 16;
77-
}
55+
const options: CypressMermaidConfig = {
56+
..._options,
57+
fontFamily: _options.fontFamily || 'courier',
58+
// @ts-ignore TODO: Fix type of fontSize
59+
fontSize: _options.fontSize || '16px',
60+
sequence: {
61+
...(_options.sequence || {}),
62+
actorFontFamily: 'courier',
63+
noteFontFamily:
64+
_options.sequence && _options.sequence.noteFontFamily
65+
? _options.sequence.noteFontFamily
66+
: 'courier',
67+
messageFontFamily: 'courier',
68+
},
69+
};
7870

7971
const url: string = mermaidUrl(graphStr, options, api);
8072
openURLAndVerifyRendering(url, options, validation);
8173
};
8274

8375
export const urlSnapshotTest = (
8476
url: string,
85-
_options: CypressMermaidConfig,
77+
options: CypressMermaidConfig,
8678
_api = false,
8779
validation?: any
8880
): void => {
89-
const options: CypressMermaidConfig = Object.assign(_options);
9081
openURLAndVerifyRendering(url, options, validation);
9182
};
9283

cypress/integration/rendering/classDiagram-v2.spec.js

+17-8
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,11 @@ describe('Class diagram V2', () => {
386386
{ logLevel: 1, flowchart: { htmlLabels: false } }
387387
);
388388
});
389-
390-
it('18: should handle the direction statement with LR', () => {
389+
it('17a: should handle the direction statement with BT', () => {
391390
imgSnapshotTest(
392391
`
393392
classDiagram
394-
direction LR
393+
direction BT
395394
class Student {
396395
-idCard : IdCard
397396
}
@@ -410,11 +409,11 @@ describe('Class diagram V2', () => {
410409
{ logLevel: 1, flowchart: { htmlLabels: false } }
411410
);
412411
});
413-
it('17a: should handle the direction statement with BT', () => {
412+
it('17b: should handle the direction statement with RL', () => {
414413
imgSnapshotTest(
415414
`
416415
classDiagram
417-
direction BT
416+
direction RL
418417
class Student {
419418
-idCard : IdCard
420419
}
@@ -433,11 +432,12 @@ describe('Class diagram V2', () => {
433432
{ logLevel: 1, flowchart: { htmlLabels: false } }
434433
);
435434
});
436-
it('17b: should handle the direction statement with RL', () => {
435+
436+
it('18a: should handle the direction statement with LR', () => {
437437
imgSnapshotTest(
438438
`
439439
classDiagram
440-
direction RL
440+
direction LR
441441
class Student {
442442
-idCard : IdCard
443443
}
@@ -457,7 +457,7 @@ describe('Class diagram V2', () => {
457457
);
458458
});
459459

460-
it('18: should render a simple class diagram with notes', () => {
460+
it('18b: should render a simple class diagram with notes', () => {
461461
imgSnapshotTest(
462462
`
463463
classDiagram-v2
@@ -562,4 +562,13 @@ class C13["With Città foreign language"]
562562
`
563563
);
564564
});
565+
it('should render a simple class diagram with no members', () => {
566+
imgSnapshotTest(
567+
`
568+
classDiagram-v2
569+
class Class10
570+
`,
571+
{ logLevel: 1, flowchart: { htmlLabels: false } }
572+
);
573+
});
565574
});

cypress/integration/rendering/conf-and-directives.spec.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { imgSnapshotTest } from '../../helpers/util.ts';
1+
import { imgSnapshotTest, urlSnapshotTest } from '../../helpers/util.ts';
22

33
describe('Configuration and directives - nodes should be light blue', () => {
44
it('No config - use default', () => {
@@ -206,8 +206,7 @@ graph TD
206206
describe('when rendering several diagrams', () => {
207207
it('diagrams should not taint later diagrams', () => {
208208
const url = 'http://localhost:9000/theme-directives.html';
209-
cy.visit(url);
210-
cy.matchImageSnapshot('conf-and-directives.spec-when-rendering-several-diagrams-diagram-1');
209+
urlSnapshotTest(url, {});
211210
});
212211
});
213212
});

cypress/integration/rendering/gantt.spec.js

+42
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,48 @@ describe('Gantt diagram', () => {
330330
);
331331
});
332332

333+
it('should render a gantt diagram with tick is 2 milliseconds', () => {
334+
imgSnapshotTest(
335+
`
336+
gantt
337+
title A Gantt Diagram
338+
dateFormat SSS
339+
axisFormat %Lms
340+
tickInterval 2millisecond
341+
excludes weekends
342+
343+
section Section
344+
A task : a1, 000, 6ms
345+
Another task : after a1, 6ms
346+
section Another
347+
Task in sec : a2, 006, 3ms
348+
another task : 3ms
349+
`,
350+
{}
351+
);
352+
});
353+
354+
it('should render a gantt diagram with tick is 2 seconds', () => {
355+
imgSnapshotTest(
356+
`
357+
gantt
358+
title A Gantt Diagram
359+
dateFormat ss
360+
axisFormat %Ss
361+
tickInterval 2second
362+
excludes weekends
363+
364+
section Section
365+
A task : a1, 00, 6s
366+
Another task : after a1, 6s
367+
section Another
368+
Task in sec : 06, 3s
369+
another task : 3s
370+
`,
371+
{}
372+
);
373+
});
374+
333375
it('should render a gantt diagram with tick is 15 minutes', () => {
334376
imgSnapshotTest(
335377
`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { urlSnapshotTest } from '../../helpers/util.ts';
2+
3+
describe('Marker Unique IDs Per Diagram', () => {
4+
it('should render a blue arrow tip in second digram', () => {
5+
urlSnapshotTest('http://localhost:9000/marker_unique_id.html', {
6+
logLevel: 1,
7+
flowchart: { htmlLabels: false },
8+
});
9+
});
10+
});
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<html>
2+
<head> </head>
3+
<body>
4+
<h1>Example</h1>
5+
<pre class="mermaid">
6+
%%{init:{"theme":"base", "themeVariables": {"lineColor":"red"}}}%%
7+
flowchart LR
8+
subgraph red
9+
A --> B
10+
end
11+
</pre>
12+
<pre class="mermaid">
13+
%%{init:{"theme":"base", "themeVariables": {"lineColor":"blue"}}}%%
14+
flowchart LR
15+
subgraph black
16+
A --> B
17+
end
18+
</pre>
19+
<pre class="mermaid">
20+
---
21+
config:
22+
theme: base
23+
themeVariables:
24+
lineColor: yellow
25+
---
26+
flowchart LR
27+
subgraph red
28+
A --> B
29+
end
30+
</pre>
31+
<pre class="mermaid">
32+
---
33+
config:
34+
theme: base
35+
themeVariables:
36+
lineColor: green
37+
---
38+
flowchart LR
39+
subgraph black
40+
A --> B
41+
end
42+
</pre>
43+
<script type="module">
44+
import mermaid from './mermaid.esm.mjs';
45+
mermaid.initialize({ startOnLoad: false, logLevel: 0 });
46+
await mermaid.run();
47+
48+
if (window.Cypress) {
49+
window.rendered = true;
50+
}
51+
</script>
52+
</body>
53+
</html>

cypress/platform/theme-directives.html

+7-21
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
<html>
22
<head>
3-
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet" />
43
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" />
5-
<link
6-
rel="stylesheet"
7-
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
8-
/>
9-
<link
10-
href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap"
11-
rel="stylesheet"
12-
/>
134
<style>
145
body {
156
/* background: rgb(221, 208, 208); */
@@ -122,26 +113,21 @@ <h1>Nothing set, should be Default</h1>
122113

123114
<script type="module">
124115
import mermaid from './mermaid.esm.mjs';
125-
mermaid.parseError = function (err, hash) {
126-
// console.error('Mermaid error: ', err);
127-
};
116+
128117
mermaid.initialize({
129-
// theme: 'dark',
130-
// theme: 'dark',
131-
// arrowMarkerAbsolute: true,
132-
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
133118
logLevel: 0,
134-
// flowchart: { useMaxWidth: true },
135119
graph: { curve: 'cardinal', htmlLabels: false },
136-
// gantt: { axisFormat: '%m/%d/%Y' },
137120
sequence: { actorMargin: 50, showSequenceNumbers: true },
138-
// sequenceDiagram: { actorMargin: 300 } // deprecated
139121
fontFamily: '"arial", sans-serif',
140122
curve: 'cardinal',
141123
securityLevel: 'strict',
124+
startOnLoad: false,
142125
});
143-
function callback() {
144-
alert('It worked');
126+
127+
await mermaid.run();
128+
129+
if (window.Cypress) {
130+
window.rendered = true;
145131
}
146132
</script>
147133
</body>

0 commit comments

Comments
 (0)