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 diagram to v3 using new renderer #5880

Merged
merged 54 commits into from
Oct 29, 2024

Conversation

yari-dewalt
Copy link
Collaborator

@yari-dewalt yari-dewalt commented Sep 19, 2024

📑 Summary

Updates the class diagram to the new unified way of rendering. Includes a new "classBox" shape to be used in diagrams as well as some other updates such as: the option to hide the empty members box in class diagrams, support for handDrawn look, the introduction of the classDef statement into class diagrams, support for styling the default class, and lollipop interfaces.

Includes fixes / additions for #5562 #3139 and #4037

📏 Design Decisions

  • The classDb gathers the necessary data and passes it to the v3 unified renderer.
  • The classBox shape is kind of complicated due to the placement and possibility of different text (annotations and members as opposed to just a plain label) as well as taking in classNode information, so it's made a little awkward. It utilizes some helper functions defined in shapeUtil to accomplish this, although I am not sure this is the best way to go about it.
  • The syntax of the class diagram and its use of specific symbols also conflicts with text creation in terms of how HTML and markdown is treated (opening and closing tags <>, - being used for lists, * being used at the end for a classifier, etc.) and so there are workarounds / hacks in place. I tried to not stray away from the typical process and so I am unsure about how acceptable these workarounds are and if they are the best method, but can revise and fix if needed.
  • The classDef statement works similarly as it does in other diagrams and defines a class that can be used in the diagram (either via the shorthand ::: or a cssClass statement).
  • Support for lollipop interfaces using ()-- and --(). This was already a supported relationship between classes, due to Class: interface realization / lollipop #1145 but now properly creates a lollipop interface instead. I left ()--() in as of right now which creates a lollipop "relation" between two classes, but it is not an official UML class relationship so unsure about leaving this in.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Copy link

changeset-bot bot commented Sep 19, 2024

⚠️ No Changeset found

Latest commit: 75ca802

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Sep 19, 2024

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 75ca802
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/6720ad9a6ac50d0008fb0cf0
😎 Deploy Preview https://deploy-preview-5880--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

pkg-pr-new bot commented Sep 19, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/mermaid-js/mermaid@5880
pnpm add https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@5880
pnpm add https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@5880
pnpm add https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@5880

commit: 75ca802

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 0.34325% with 871 lines in your changes missing coverage. Please review.

Project coverage is 4.50%. Comparing base (3f85b61) to head (75ca802).
Report is 61 commits behind head on develop.

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/class/classDb.ts 0.00% 238 Missing ⚠️
packages/mermaid/src/diagrams/class/shapeUtil.ts 0.00% 223 Missing ⚠️
...ndering-util/rendering-elements/shapes/classBox.ts 0.00% 207 Missing ⚠️
...aid/src/diagrams/class/classRenderer-v3-unified.ts 0.00% 79 Missing ⚠️
packages/mermaid/src/utils/lineWithOffset.ts 0.00% 73 Missing ⚠️
packages/mermaid/src/diagrams/class/classTypes.ts 0.00% 27 Missing ⚠️
...id/src/rendering-util/rendering-elements/shapes.ts 0.00% 9 Missing ⚠️
packages/mermaid-layout-elk/src/render.ts 0.00% 6 Missing ⚠️
packages/mermaid/src/diagrams/class/styles.js 0.00% 4 Missing ⚠️
...mermaid/src/rendering-util/handle-markdown-text.ts 0.00% 2 Missing ⚠️
... and 3 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #5880      +/-   ##
==========================================
- Coverage     4.56%   4.50%   -0.07%     
==========================================
  Files          380     383       +3     
  Lines        53015   53856     +841     
  Branches       619     622       +3     
==========================================
+ Hits          2422    2425       +3     
- Misses       50593   51431     +838     
Flag Coverage Δ
unit 4.50% <0.34%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/mermaid/src/defaultConfig.ts 45.38% <100.00%> (+0.61%) ⬆️
...aid/src/rendering-util/rendering-elements/edges.js 0.00% <ø> (ø)
...ages/mermaid/src/diagrams/class/classDiagram-v2.ts 0.00% <0.00%> (ø)
...ackages/mermaid/src/diagrams/class/classDiagram.ts 0.00% <0.00%> (ø)
packages/mermaid/src/utils.ts 41.98% <0.00%> (-0.05%) ⬇️
...mermaid/src/rendering-util/handle-markdown-text.ts 0.00% <0.00%> (ø)
packages/mermaid/src/diagrams/class/styles.js 0.00% <0.00%> (ø)
packages/mermaid-layout-elk/src/render.ts 0.00% <0.00%> (ø)
...id/src/rendering-util/rendering-elements/shapes.ts 0.00% <0.00%> (ø)
packages/mermaid/src/diagrams/class/classTypes.ts 0.00% <0.00%> (ø)
... and 5 more

@yari-dewalt
Copy link
Collaborator Author

@jgreywolf

@yari-dewalt What is the status of this?

Changes are fully reviewed now, so going through and fixing and then it should be good!

@yari-dewalt
Copy link
Collaborator Author

E2E tests failing because of screenshot capacity

An error was thrown in your plugins file while executing the handler for the after:run event.

The error we received was:

Error: You have reached the maximum screenshot capacity included in your Pro open source xl Plan. Please upgrade your Plan.
at throwAPIError (file:///__w/mermaid/mermaid/node_modules/.pnpm/@argos-ci[email protected]/node_modules/@argos-ci/api-client/dist/index.mjs:28:15)
at upload (file:///__w/mermaid/mermaid/node_modules/.pnpm/@argos-ci[email protected]/node_modules/@argos-ci/core/dist/index.mjs:886:9)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object. (file:///__w/mermaid/mermaid/node_modules/.pnpm/@argos-ci[email protected][email protected]/node_modules/@argos-ci/cypress/dist/task.mjs:32:21)
at async Object.handlerThatCallsUserDefinedHandler [as handler] (/__w/mermaid/mermaid/node_modules/.pnpm/@applitools[email protected][email protected][email protected]/node_modules/@applitools/eyes-cypress/dist/plugin/pluginExport.js:105:21)
Test run failed, code 1
More information might be available above
Cypress module has returned the following error message:
Could not find Cypress test run results
Error: Could not find Cypress test run results

@knsv knsv merged commit bdf145f into mermaid-js:develop Oct 29, 2024
10 of 14 checks passed
Copy link

mermaid-bot bot commented Oct 29, 2024

@yari-dewalt, Thank you for the contribution!
You are now eligible for a year of Premium account on MermaidChart.
Sign up with your GitHub account to activate.

aloisklink added a commit that referenced this pull request Oct 30, 2024
This isn't documented, but apparently changesets supports this in changesets/changesets@91d1ef2

This is needed to give @yari-dewalt credit for PR #5880
knsv added a commit that referenced this pull request Oct 30, 2024
@github-actions github-actions bot mentioned this pull request Oct 30, 2024
kairi003 added a commit to kairi003/mermaid that referenced this pull request Nov 9, 2024
kairi003 added a commit to kairi003/mermaid that referenced this pull request Nov 9, 2024
kairi003 added a commit to kairi003/mermaid that referenced this pull request Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants