-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Conversation
Looks like the unit tests caught a valid issue. |
I think this is something to be discussed - In theory I think that this test is invalid. I say in theory - because when creating a class member if the the first character is a ~, it basically gets stripped out, and will not be present in the text that is sent to the function. However, if something else decides to call that function which is outside of classes, then that convention would not be "forced" |
Ok, so if it's an invalid test, let's remove it. |
Yes - I had left it in for now to have the discussion ;) |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #4534 +/- ##
===========================================
- Coverage 77.05% 73.45% -3.60%
===========================================
Files 146 146
Lines 14573 14487 -86
Branches 592 612 +20
===========================================
- Hits 11229 10642 -587
- Misses 3225 3704 +479
- Partials 119 141 +22
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@knsv @sidharthv96 Please review |
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.
I'm not knowledgeable in class diagrams, so please take my review with a grain of salt!
Adding the new ClassMember
class is a change I love! It can be pretty difficult for me to understand some of diagram parsing/DB code, so this definitely makes it easier to understand.
Before merging, is there any chance you can add some TSDoc comments to the ClassMember
class? Ideally every publicly available method and field should have a short description.
Co-authored-by: Alois Klink <alois@aloisklink.com>
@jgreywolf the tests failures look like valid errors. So please fix those. |
Ill have to wait for the new actions to finish, because I pushed a small update. You say multiple? Thats frustrating - all looked good here :( |
@sidharthv96 errors went away after rerunning. |
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.
@jgreywolf we can merge this once you review #4805
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 job fixing all these issues! Loved the new approach.
@jgreywolf, Thank you for the contribution! |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [mermaid](https://togithub.com/mermaid-js/mermaid) | [`10.4.0` -> `10.5.0`](https://renovatebot.com/diffs/npm/mermaid/10.4.0/10.5.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/mermaid/10.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/mermaid/10.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/mermaid/10.4.0/10.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/mermaid/10.4.0/10.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>mermaid-js/mermaid (mermaid)</summary> ### [`v10.5.0`](https://togithub.com/mermaid-js/mermaid/releases/tag/v10.5.0): 10.5.0 [Compare Source](https://togithub.com/mermaid-js/mermaid/compare/v10.4.0...v10.5.0) #### What's Changed ##### Features - feat(er): add entity name alias by [@​tomperr](https://togithub.com/tomperr) in [https://github.com/mermaid-js/mermaid/pull/4758](https://togithub.com/mermaid-js/mermaid/pull/4758) ##### Bugfixes - Fix Twitter fontawesome class in flowchart.md by [@​GingerNinjaNicko](https://togithub.com/GingerNinjaNicko) in [https://github.com/mermaid-js/mermaid/pull/4723](https://togithub.com/mermaid-js/mermaid/pull/4723) - fix(pie): align slices and legend orders by [@​Yokozuna59](https://togithub.com/Yokozuna59) in [https://github.com/mermaid-js/mermaid/pull/4774](https://togithub.com/mermaid-js/mermaid/pull/4774) - Update class member handling by [@​jgreywolf](https://togithub.com/jgreywolf) in [https://github.com/mermaid-js/mermaid/pull/4534](https://togithub.com/mermaid-js/mermaid/pull/4534) - fix(er): allow underscore as leading char by [@​tomperr](https://togithub.com/tomperr) in [https://github.com/mermaid-js/mermaid/pull/4776](https://togithub.com/mermaid-js/mermaid/pull/4776) - Align arrows on sequence diagram by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4804](https://togithub.com/mermaid-js/mermaid/pull/4804) - fix: Allow hollow markers on edges by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4788](https://togithub.com/mermaid-js/mermaid/pull/4788) - fix: Fix for vulnerability making it possible to add javascript in class names by [@​knsv](https://togithub.com/knsv) ##### Documentation - Docs/2910 Remove n00b and fix some docs by [@​nirname](https://togithub.com/nirname) in [https://github.com/mermaid-js/mermaid/pull/4767](https://togithub.com/mermaid-js/mermaid/pull/4767) - fix: typos by [@​omahs](https://togithub.com/omahs) in [https://github.com/mermaid-js/mermaid/pull/4801](https://togithub.com/mermaid-js/mermaid/pull/4801) - "CSS" instead of "css" in flowchart.md by [@​jakeboone02](https://togithub.com/jakeboone02) in [https://github.com/mermaid-js/mermaid/pull/4797](https://togithub.com/mermaid-js/mermaid/pull/4797) - fix(docs): Correct repeated text in flowchart.md by [@​andriy-koz](https://togithub.com/andriy-koz) in [https://github.com/mermaid-js/mermaid/pull/4810](https://togithub.com/mermaid-js/mermaid/pull/4810) - Update link to Discourse theme component by [@​gschlager](https://togithub.com/gschlager) in [https://github.com/mermaid-js/mermaid/pull/4811](https://togithub.com/mermaid-js/mermaid/pull/4811) - New Mermaid Live Editor for Confluence Cloud by [@​zhifeiyue](https://togithub.com/zhifeiyue) in [https://github.com/mermaid-js/mermaid/pull/4814](https://togithub.com/mermaid-js/mermaid/pull/4814) - Update classDiagram.md by [@​jgreywolf](https://togithub.com/jgreywolf) in [https://github.com/mermaid-js/mermaid/pull/4781](https://togithub.com/mermaid-js/mermaid/pull/4781) - Support member definition to initialize class by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4786](https://togithub.com/mermaid-js/mermaid/pull/4786) - fix: Add support for `~test Array~string~` back in Class by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4805](https://togithub.com/mermaid-js/mermaid/pull/4805) - Added support for millisecond and second to gantt tickInterval by [@​vertxxyz](https://togithub.com/vertxxyz) in [https://github.com/mermaid-js/mermaid/pull/4778](https://togithub.com/mermaid-js/mermaid/pull/4778) - Add directive support to all diagrams by preprocessing by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4759](https://togithub.com/mermaid-js/mermaid/pull/4759) - Update README.md by [@​jgreywolf](https://togithub.com/jgreywolf) in [https://github.com/mermaid-js/mermaid/pull/4780](https://togithub.com/mermaid-js/mermaid/pull/4780) ##### Chores - chore(deps): update all minor dependencies (minor) by [@​renovate](https://togithub.com/renovate) in [https://github.com/mermaid-js/mermaid/pull/4783](https://togithub.com/mermaid-js/mermaid/pull/4783) - chore(deps): update all patch dependencies (patch) by [@​renovate](https://togithub.com/renovate) in [https://github.com/mermaid-js/mermaid/pull/4782](https://togithub.com/mermaid-js/mermaid/pull/4782) - chore(deps): update all patch dependencies (patch) by [@​renovate](https://togithub.com/renovate) in [https://github.com/mermaid-js/mermaid/pull/4809](https://togithub.com/mermaid-js/mermaid/pull/4809) - chore: move `commonDb` into `diagrams/common/commonDb` by [@​Yokozuna59](https://togithub.com/Yokozuna59) in [https://github.com/mermaid-js/mermaid/pull/4802](https://togithub.com/mermaid-js/mermaid/pull/4802) - Use utf8 encoding in Jupyter example by [@​jonashaag](https://togithub.com/jonashaag) in [https://github.com/mermaid-js/mermaid/pull/4701](https://togithub.com/mermaid-js/mermaid/pull/4701) - Update flowchart.md by [@​Ogglas](https://togithub.com/Ogglas) in [https://github.com/mermaid-js/mermaid/pull/4792](https://togithub.com/mermaid-js/mermaid/pull/4792) - Update flowchart.md by [@​dsblank](https://togithub.com/dsblank) in [https://github.com/mermaid-js/mermaid/pull/4798](https://togithub.com/mermaid-js/mermaid/pull/4798) - Refactor `cypress/helpers/util.ts` by [@​RohanHandore](https://togithub.com/RohanHandore) in [https://github.com/mermaid-js/mermaid/pull/4340](https://togithub.com/mermaid-js/mermaid/pull/4340) - refactor: Fix typings in utils.ts by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4826](https://togithub.com/mermaid-js/mermaid/pull/4826) - Support ClassDefs in external diagrams by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4819](https://togithub.com/mermaid-js/mermaid/pull/4819) - Fix: flowchartElk Arrow overlap by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4830](https://togithub.com/mermaid-js/mermaid/pull/4830) - Give markers unique id's per graph by [@​chadfawcett](https://togithub.com/chadfawcett) in [https://github.com/mermaid-js/mermaid/pull/4825](https://togithub.com/mermaid-js/mermaid/pull/4825) #### New Contributors - [@​GingerNinjaNicko](https://togithub.com/GingerNinjaNicko) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4723](https://togithub.com/mermaid-js/mermaid/pull/4723) - [@​omahs](https://togithub.com/omahs) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4801](https://togithub.com/mermaid-js/mermaid/pull/4801) - [@​jakeboone02](https://togithub.com/jakeboone02) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4797](https://togithub.com/mermaid-js/mermaid/pull/4797) - [@​andriy-koz](https://togithub.com/andriy-koz) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4810](https://togithub.com/mermaid-js/mermaid/pull/4810) - [@​gschlager](https://togithub.com/gschlager) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4811](https://togithub.com/mermaid-js/mermaid/pull/4811) - [@​zhifeiyue](https://togithub.com/zhifeiyue) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4814](https://togithub.com/mermaid-js/mermaid/pull/4814) - [@​vertxxyz](https://togithub.com/vertxxyz) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4778](https://togithub.com/mermaid-js/mermaid/pull/4778) - [@​jonashaag](https://togithub.com/jonashaag) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4701](https://togithub.com/mermaid-js/mermaid/pull/4701) - [@​Ogglas](https://togithub.com/Ogglas) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4792](https://togithub.com/mermaid-js/mermaid/pull/4792) - [@​dsblank](https://togithub.com/dsblank) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4798](https://togithub.com/mermaid-js/mermaid/pull/4798) - [@​RohanHandore](https://togithub.com/RohanHandore) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4340](https://togithub.com/mermaid-js/mermaid/pull/4340) - [@​chadfawcett](https://togithub.com/chadfawcett) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4825](https://togithub.com/mermaid-js/mermaid/pull/4825) **Full Changelog**: mermaid-js/mermaid@v10.4.0...v10.5.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/levaintech/contented). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjMiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
📑 Summary
The intent of this PR is to streamline the logic for parsing member statements for classes, and to make it then easier to fix other issues. This PR includes:
fixes around comments
properly handling different scenarios around generics
initial work to not show members box if there are no attributes or methods
handle leading newlines
changed name from "member" to "attribute" to be explicit and distinct from members as a whole
resolves Cannot have Generic of Generics in Class diagram #3287
resolves Comments in
classDiagram
should be allowed inside of Class definitions #1645resolves Property strings on class diagrams #3189
resolves error in parser when string to parse is \nclassDiagram #3243
partial Method return not displayed in Class Diagram when using JavaScript computed method names #2185
📏 Design Decisions
Added a new class for members specifically, and all parsing of that member is handled within the class itself. Created a more thorough regex specific for methods to capture any of the expected values - or have an empty result if that value was not matched. There has been talk about whether or not the type or name of an attribute or method parameter should go first - so handling is set to take however the value is typed for that section
📋 Tasks
Make sure you
develop
branch