-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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 classId generation to use generic type #5223
Update classId generation to use generic type #5223
Conversation
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This should help out a lot of people.
Is this a breaking change though? (Or did the previous implementation not support this at all?)
Should we fall back to previous behavior, so existing diagrams don't break?
If the diagram refers class without type, we could pick whichever class was defined first (or whatever the current behaviour is)?
We need rendering tests as well.
cc @knsv
Co-authored-by: Sidharth Vinod <[email protected]>
… of https://github.com/mermaid-js/mermaid into bug/4762_class-diagram-generic-type-info-in-class-name
The previous implemetation did not support this at all. This should not be a breaking change, any existing class diagrams will still parse the same as they did before |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5223 +/- ##
==========================================
- Coverage 5.72% 5.72% -0.01%
==========================================
Files 277 277
Lines 41896 41902 +6
Branches 27 27
==========================================
Hits 2400 2400
- Misses 39495 39501 +6
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There are already rendering tests that cover use of generic in class name |
@sidharthv96 This is assuming that the test result images are showing the old (expected) on the left, and the new (received) is on the left |
That's fine. Yes it's like you mentioned. |
…in-class-name * develop: (501 commits) Add extra test Add visual test Wait for image to be rendered Update docs Linting chore: temp fix for eslint OOM chore: Update error snapshots Fix ESLint chore: Prettier chore: YOLO `pnpm --recursive update` chore: Remove commitlint Fix flowchart-elk render test chore: Add example page link in index Fix flowchart-elk render test chore: Add example page link in index fix: Remove space which caused extra newline on diagrams fix: Remove repeated config calls fix: ELK diagram remove re-parsing chore: Minor fixes #4856 chore: Increase ESLint memory limit ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous implemetation did not support this at all. This should not be a breaking change, any existing class diagrams will still parse the same as they did before
Consider this diagram
classDiagram
class Class01~T~
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
class Class10~T~ {
<<service>>
int id
test()
}
So this infact breaks existing diagrams. So we should add a fallback so the diagram will render the same.
FYI - I am redoing this slightly as part of a separate PR (too many conflicts). Im not sure this is the best solution anymore either. I mentioned to someone else recently, that I totally regret using |
📑 Summary
In order to allow class diagrams where there are multiple generic classes with the same name, only different type parameter, updated the classId generation logic to append
-TYPE
to the end of class name to get the id.However, this means that any later referrals to that class needs to either be in the format
class~T~
orclass-T
to ensure that the correct class is utilized.Resolves #4762
📏 Design Decisions
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.develop
branch