Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update class member handling #4534

Merged
merged 30 commits into from Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0aa09bf
Create new type for member handling
jgreywolf May 30, 2023
b0b3c7f
Update and add tests
jgreywolf Jun 2, 2023
f4ffd5c
Merge branch 'develop' into UpdateClassMemberHandling
jgreywolf Jun 9, 2023
164605b
update classes to handle , in generic
jgreywolf Jun 12, 2023
a9ee184
spec changes
jgreywolf Jun 12, 2023
b32da2b
Fix tests
jgreywolf Jun 25, 2023
3718274
Merge branch 'develop' into UpdateClassMemberHandling
jgreywolf Jun 28, 2023
7b2ef11
update tests and db name
jgreywolf Jun 28, 2023
6abf0f1
Merge branch 'develop' into UpdateClassMemberHandling
jgreywolf Jun 29, 2023
1d391d9
Merge branch 'develop' into UpdateClassMemberHandling
jgreywolf Jul 3, 2023
8435330
Update packages/mermaid/src/diagrams/class/classTypes.ts
jgreywolf Jul 3, 2023
c001520
Update packages/mermaid/src/diagrams/class/classTypes.ts
jgreywolf Jul 3, 2023
e29d2b2
apply suggesitons
jgreywolf Jul 3, 2023
02acf9d
Merge branch 'UpdateClassMemberHandling' of https://github.com/mermai…
jgreywolf Jul 3, 2023
6ed0c9b
update tests
jgreywolf Aug 15, 2023
9a9abac
Merge branch 'develop' into UpdateClassMemberHandling
jgreywolf Aug 15, 2023
bbaab54
add tsdoc comments
jgreywolf Aug 15, 2023
3f32719
return comment
jgreywolf Aug 15, 2023
3ec3252
Update packages/mermaid/src/diagrams/class/svgDraw.js
jgreywolf Aug 23, 2023
0881619
Merge branch 'UpdateClassMemberHandling' of https://github.com/mermai…
jgreywolf Aug 24, 2023
8b96282
improvements to parseGenericTypes
jgreywolf Aug 25, 2023
8e64995
Merge branch 'develop' into UpdateClassMemberHandling
jgreywolf Aug 25, 2023
3678ad4
modifications to generic parser
jgreywolf Aug 25, 2023
fa6198b
Update docs
jgreywolf Aug 25, 2023
5a2b3db
Merge branch 'develop' into UpdateClassMemberHandling
jgreywolf Aug 25, 2023
87880fd
add sanitize text
jgreywolf Aug 26, 2023
b513169
Merge branch 'develop' into UpdateClassMemberHandling
jgreywolf Aug 26, 2023
12f11c6
added test case
jgreywolf Aug 27, 2023
5839e0d
add additional test case
jgreywolf Aug 28, 2023
05c2a11
chore: Align with convention
sidharthv96 Sep 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions cSpell.json
Expand Up @@ -38,7 +38,10 @@
"docsy",
"doku",
"dompurify",
"dont",
"doublecircle",
"edgechromium",
"elems",
"elkjs",
"faber",
"flatmap",
Expand Down
25 changes: 17 additions & 8 deletions cypress/integration/rendering/classDiagram-v2.spec.js
Expand Up @@ -386,12 +386,11 @@ describe('Class diagram V2', () => {
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
});

it('18: should handle the direction statement with LR', () => {
it('17a: should handle the direction statement with BT', () => {
imgSnapshotTest(
`
classDiagram
direction LR
direction BT
class Student {
-idCard : IdCard
}
Expand All @@ -410,11 +409,11 @@ describe('Class diagram V2', () => {
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
});
it('17a: should handle the direction statement with BT', () => {
it('17b: should handle the direction statement with RL', () => {
imgSnapshotTest(
`
classDiagram
direction BT
direction RL
class Student {
-idCard : IdCard
}
Expand All @@ -433,11 +432,12 @@ describe('Class diagram V2', () => {
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
});
it('17b: should handle the direction statement with RL', () => {

it('18a: should handle the direction statement with LR', () => {
aloisklink marked this conversation as resolved.
Show resolved Hide resolved
imgSnapshotTest(
`
classDiagram
direction RL
direction LR
class Student {
-idCard : IdCard
}
Expand All @@ -457,7 +457,7 @@ describe('Class diagram V2', () => {
);
});

it('18: should render a simple class diagram with notes', () => {
it('18b: should render a simple class diagram with notes', () => {
imgSnapshotTest(
`
classDiagram-v2
Expand Down Expand Up @@ -562,4 +562,13 @@ class C13["With Città foreign language"]
`
);
});
it('should render a simple class diagram with no members', () => {
imgSnapshotTest(
`
classDiagram-v2
class Class10
`,
{ logLevel: 1, flowchart: { htmlLabels: false } }
);
});
});
4 changes: 4 additions & 0 deletions demos/classchart.html
Expand Up @@ -80,6 +80,7 @@ <h1>Class diagram demos</h1>
Class01 : #size()
Class01 : -int chimp
Class01 : +int gorilla
Class01 : +abstractAttribute string*
class Class10~T~ {
&lt;&lt;service&gt;&gt;
int id
Expand Down Expand Up @@ -122,6 +123,8 @@ <h1>Class diagram demos</h1>
classDiagram
direction LR
Animal ()-- Dog
Animal ()-- Cat
note for Cat "should have no members area"
Dog : bark()
Dog : species()
</pre>
Expand Down Expand Up @@ -151,6 +154,7 @@ <h1>Class diagram demos</h1>
~InternalProperty : string
~AnotherInternalProperty : List~List~string~~
}
class People~List~Person~~
</pre>
<hr />

Expand Down
9 changes: 4 additions & 5 deletions packages/mermaid/src/dagre-wrapper/nodes.js
Expand Up @@ -5,7 +5,6 @@ import { getConfig } from '../config.js';
import intersect from './intersect/index.js';
import createLabel from './createLabel.js';
import note from './shapes/note.js';
import { parseMember } from '../diagrams/class/svgDraw.js';
import { evaluate } from '../diagrams/common/common.js';

const question = async (parent, node) => {
Expand Down Expand Up @@ -806,8 +805,8 @@ const class_box = (parent, node) => {
maxWidth = classTitleBBox.width;
}
const classAttributes = [];
node.classData.members.forEach((str) => {
const parsedInfo = parseMember(str);
node.classData.members.forEach((member) => {
const parsedInfo = member.getDisplayDetails();
let parsedText = parsedInfo.displayText;
if (getConfig().flowchart.htmlLabels) {
parsedText = parsedText.replace(/</g, '&lt;').replace(/>/g, '&gt;');
Expand Down Expand Up @@ -840,8 +839,8 @@ const class_box = (parent, node) => {
maxHeight += lineHeight;

const classMethods = [];
node.classData.methods.forEach((str) => {
const parsedInfo = parseMember(str);
node.classData.methods.forEach((member) => {
const parsedInfo = member.getDisplayDetails();
let displayText = parsedInfo.displayText;
if (getConfig().flowchart.htmlLabels) {
displayText = displayText.replace(/</g, '&lt;').replace(/>/g, '&gt;');
Expand Down
@@ -1,10 +1,10 @@
import { parser } from './parser/classDiagram.jison';
import classDb from './classDb.js';
import classParser from './classParser.js';

describe('class diagram, ', function () {
describe('when parsing data from a classDiagram it', function () {
beforeEach(function () {
parser.yy = classDb;
parser.yy = classParser;
parser.yy.clear();
});

Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/class/classDiagram-v2.ts
@@ -1,7 +1,7 @@
import { DiagramDefinition } from '../../diagram-api/types.js';
// @ts-ignore: TODO Fix ts errors
import parser from './parser/classDiagram.jison';
import db from './classDb.js';
import db from './classParser.js';
import styles from './styles.js';
import renderer from './classRenderer-v2.js';

Expand Down