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

Draft
wants to merge 26 commits into
base: develop
Choose a base branch
from

Conversation

yari-dewalt
Copy link
Collaborator

📑 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, and the introduction of the classDef statement into class diagrams.

📏 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).

📋 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: 41f2286

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 41f2286
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/66ec82d4f6a1020008fcd395
😎 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/layout-elk@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/mermaid-zenuml@5880

commit: 41f2286

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 0.44577% with 670 lines in your changes missing coverage. Please review.

Project coverage is 4.94%. Comparing base (a07f1f3) to head (41f2286).

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/class/shapeUtil.ts 0.00% 219 Missing ⚠️
...ndering-util/rendering-elements/shapes/classBox.ts 0.00% 176 Missing ⚠️
packages/mermaid/src/diagrams/class/classDb.ts 0.00% 169 Missing ⚠️
...aid/src/diagrams/class/classRenderer-v3-unified.ts 0.00% 79 Missing ⚠️
packages/mermaid/src/diagrams/class/classTypes.ts 0.00% 20 Missing ⚠️
...mermaid/src/rendering-util/handle-markdown-text.ts 0.00% 2 Missing ⚠️
...aid/src/rendering-util/rendering-elements/nodes.js 0.00% 2 Missing ⚠️
...ages/mermaid/src/diagrams/class/classDiagram-v2.ts 0.00% 1 Missing ⚠️
...ackages/mermaid/src/diagrams/class/classDiagram.ts 0.00% 1 Missing ⚠️
packages/mermaid/src/utils.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #5880      +/-   ##
==========================================
- Coverage     5.00%   4.94%   -0.07%     
==========================================
  Files          337     340       +3     
  Lines        48209   48876     +667     
  Branches       576     579       +3     
==========================================
+ Hits          2413    2416       +3     
- Misses       45796   46460     +664     
Flag Coverage Δ
unit 4.94% <0.44%> (-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.18% <100.00%> (+0.61%) ⬆️
...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.67% <0.00%> (-0.05%) ⬇️
...mermaid/src/rendering-util/handle-markdown-text.ts 0.00% <0.00%> (ø)
...aid/src/rendering-util/rendering-elements/nodes.js 0.00% <0.00%> (ø)
packages/mermaid/src/diagrams/class/classTypes.ts 0.00% <0.00%> (ø)
...aid/src/diagrams/class/classRenderer-v3-unified.ts 0.00% <0.00%> (ø)
packages/mermaid/src/diagrams/class/classDb.ts 0.00% <0.00%> (ø)
...ndering-util/rendering-elements/shapes/classBox.ts 0.00% <0.00%> (ø)
... and 1 more

Copy link

argos-ci bot commented Sep 19, 2024

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 46 changed, 56 added Sep 19, 2024, 8:13 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant