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

Update class member handling #4534

merged 30 commits into from Sep 3, 2023

Conversation

jgreywolf
Copy link
Contributor

📑 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:

📏 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

  • 📖 have read the contribution guidelines
  • 💻 have added unit/e2e tests (if appropriate)
  • 📓 have added documentation (if appropriate)
  • 🔖 targeted develop branch

@sidharthv96
Copy link
Member

Looks like the unit tests caught a valid issue.

@jgreywolf
Copy link
Contributor Author

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"

@sidharthv96
Copy link
Member

Ok, so if it's an invalid test, let's remove it.

@jgreywolf
Copy link
Contributor Author

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-commenter
Copy link

codecov-commenter commented Jun 28, 2023

Codecov Report

Merging #4534 (05c2a11) into develop (ed819e9) will decrease coverage by 3.60%.
Report is 4 commits behind head on develop.
The diff coverage is 65.42%.

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 79.18% <81.17%> (-4.74%) ⬇️
unit 45.34% <7.54%> (-0.22%) ⬇️

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

Files Changed Coverage Δ
...ges/mermaid/src/diagrams/class/classRenderer-v2.ts 79.85% <ø> (ø)
packages/mermaid/src/diagrams/common/common.ts 71.03% <41.50%> (-3.97%) ⬇️
packages/mermaid/src/diagrams/class/classTypes.ts 86.95% <86.95%> (ø)
packages/mermaid/src/dagre-wrapper/nodes.js 81.45% <100.00%> (-8.17%) ⬇️
packages/mermaid/src/diagrams/class/classDb.ts 82.35% <100.00%> (+8.55%) ⬆️

... and 23 files with indirect coverage changes

@jgreywolf
Copy link
Contributor Author

@knsv @sidharthv96 Please review

Copy link
Member

@aloisklink aloisklink left a 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.

packages/mermaid/src/diagrams/class/classRenderer-v2.ts Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/class/classTypes.ts Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/class/classTypes.ts Outdated Show resolved Hide resolved
packages/mermaid/src/diagrams/class/classTypes.ts Outdated Show resolved Hide resolved
@jgreywolf jgreywolf requested a review from jakraft August 25, 2023 18:07
@sidharthv96
Copy link
Member

@jgreywolf the tests failures look like valid errors. So please fix those.

@jgreywolf
Copy link
Contributor Author

@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 :(

@jgreywolf
Copy link
Contributor Author

@sidharthv96 errors went away after rerunning.

@jgreywolf jgreywolf linked an issue Aug 27, 2023 that may be closed by this pull request
Copy link
Member

@sidharthv96 sidharthv96 left a 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

Copy link
Member

@sidharthv96 sidharthv96 left a 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.

@sidharthv96 sidharthv96 added this pull request to the merge queue Sep 3, 2023
Merged via the queue into develop with commit 69b4b48 Sep 3, 2023
25 of 26 checks passed
@mermaid-bot
Copy link

mermaid-bot bot commented Sep 3, 2023

@jgreywolf, 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.

@jgreywolf jgreywolf deleted the UpdateClassMemberHandling branch September 5, 2023 15:55
fuxingloh pushed a commit to fuxingloh/contented that referenced this pull request Oct 3, 2023
[![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
[@&#8203;tomperr](https://togithub.com/tomperr) in
[mermaid-js/mermaid#4758

##### Bugfixes

- Fix Twitter fontawesome class in flowchart.md by
[@&#8203;GingerNinjaNicko](https://togithub.com/GingerNinjaNicko) in
[mermaid-js/mermaid#4723
- fix(pie): align slices and legend orders by
[@&#8203;Yokozuna59](https://togithub.com/Yokozuna59) in
[mermaid-js/mermaid#4774
- Update class member handling by
[@&#8203;jgreywolf](https://togithub.com/jgreywolf) in
[mermaid-js/mermaid#4534
- fix(er): allow underscore as leading char by
[@&#8203;tomperr](https://togithub.com/tomperr) in
[mermaid-js/mermaid#4776
- Align arrows on sequence diagram by
[@&#8203;sidharthv96](https://togithub.com/sidharthv96) in
[mermaid-js/mermaid#4804
- fix: Allow hollow markers on edges by
[@&#8203;sidharthv96](https://togithub.com/sidharthv96) in
[mermaid-js/mermaid#4788
- fix: Fix for vulnerability making it possible to add javascript in
class names by [@&#8203;knsv](https://togithub.com/knsv)

##### Documentation

- Docs/2910 Remove n00b and fix some docs by
[@&#8203;nirname](https://togithub.com/nirname) in
[mermaid-js/mermaid#4767
- fix: typos by [@&#8203;omahs](https://togithub.com/omahs) in
[mermaid-js/mermaid#4801
- "CSS" instead of "css" in flowchart.md by
[@&#8203;jakeboone02](https://togithub.com/jakeboone02) in
[mermaid-js/mermaid#4797
- fix(docs): Correct repeated text in flowchart.md by
[@&#8203;andriy-koz](https://togithub.com/andriy-koz) in
[mermaid-js/mermaid#4810
- Update link to Discourse theme component by
[@&#8203;gschlager](https://togithub.com/gschlager) in
[mermaid-js/mermaid#4811
- New Mermaid Live Editor for Confluence Cloud by
[@&#8203;zhifeiyue](https://togithub.com/zhifeiyue) in
[mermaid-js/mermaid#4814
- Update classDiagram.md by
[@&#8203;jgreywolf](https://togithub.com/jgreywolf) in
[mermaid-js/mermaid#4781
- Support member definition to initialize class by
[@&#8203;sidharthv96](https://togithub.com/sidharthv96) in
[mermaid-js/mermaid#4786
- fix: Add support for `~test Array~string~` back in Class by
[@&#8203;sidharthv96](https://togithub.com/sidharthv96) in
[mermaid-js/mermaid#4805
- Added support for millisecond and second to gantt tickInterval by
[@&#8203;vertxxyz](https://togithub.com/vertxxyz) in
[mermaid-js/mermaid#4778
- Add directive support to all diagrams by preprocessing by
[@&#8203;sidharthv96](https://togithub.com/sidharthv96) in
[mermaid-js/mermaid#4759
- Update README.md by
[@&#8203;jgreywolf](https://togithub.com/jgreywolf) in
[mermaid-js/mermaid#4780

##### Chores

- chore(deps): update all minor dependencies (minor) by
[@&#8203;renovate](https://togithub.com/renovate) in
[mermaid-js/mermaid#4783
- chore(deps): update all patch dependencies (patch) by
[@&#8203;renovate](https://togithub.com/renovate) in
[mermaid-js/mermaid#4782
- chore(deps): update all patch dependencies (patch) by
[@&#8203;renovate](https://togithub.com/renovate) in
[mermaid-js/mermaid#4809
- chore: move `commonDb` into `diagrams/common/commonDb` by
[@&#8203;Yokozuna59](https://togithub.com/Yokozuna59) in
[mermaid-js/mermaid#4802
- Use utf8 encoding in Jupyter example by
[@&#8203;jonashaag](https://togithub.com/jonashaag) in
[mermaid-js/mermaid#4701
- Update flowchart.md by [@&#8203;Ogglas](https://togithub.com/Ogglas)
in
[mermaid-js/mermaid#4792
- Update flowchart.md by [@&#8203;dsblank](https://togithub.com/dsblank)
in
[mermaid-js/mermaid#4798
- Refactor `cypress/helpers/util.ts` by
[@&#8203;RohanHandore](https://togithub.com/RohanHandore) in
[mermaid-js/mermaid#4340
- refactor: Fix typings in utils.ts by
[@&#8203;sidharthv96](https://togithub.com/sidharthv96) in
[mermaid-js/mermaid#4826
- Support ClassDefs in external diagrams by
[@&#8203;sidharthv96](https://togithub.com/sidharthv96) in
[mermaid-js/mermaid#4819
- Fix: flowchartElk Arrow overlap by
[@&#8203;sidharthv96](https://togithub.com/sidharthv96) in
[mermaid-js/mermaid#4830
- Give markers unique id's per graph by
[@&#8203;chadfawcett](https://togithub.com/chadfawcett) in
[mermaid-js/mermaid#4825

#### New Contributors

- [@&#8203;GingerNinjaNicko](https://togithub.com/GingerNinjaNicko) made
their first contribution in
[mermaid-js/mermaid#4723
- [@&#8203;omahs](https://togithub.com/omahs) made their first
contribution in
[mermaid-js/mermaid#4801
- [@&#8203;jakeboone02](https://togithub.com/jakeboone02) made their
first contribution in
[mermaid-js/mermaid#4797
- [@&#8203;andriy-koz](https://togithub.com/andriy-koz) made their first
contribution in
[mermaid-js/mermaid#4810
- [@&#8203;gschlager](https://togithub.com/gschlager) made their first
contribution in
[mermaid-js/mermaid#4811
- [@&#8203;zhifeiyue](https://togithub.com/zhifeiyue) made their first
contribution in
[mermaid-js/mermaid#4814
- [@&#8203;vertxxyz](https://togithub.com/vertxxyz) made their first
contribution in
[mermaid-js/mermaid#4778
- [@&#8203;jonashaag](https://togithub.com/jonashaag) made their first
contribution in
[mermaid-js/mermaid#4701
- [@&#8203;Ogglas](https://togithub.com/Ogglas) made their first
contribution in
[mermaid-js/mermaid#4792
- [@&#8203;dsblank](https://togithub.com/dsblank) made their first
contribution in
[mermaid-js/mermaid#4798
- [@&#8203;RohanHandore](https://togithub.com/RohanHandore) made their
first contribution in
[mermaid-js/mermaid#4340
- [@&#8203;chadfawcett](https://togithub.com/chadfawcett) made their
first contribution in
[mermaid-js/mermaid#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants