-
-
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
Updated the code to include nested namespaces for class diagrams #5849
Updated the code to include nested namespaces for class diagrams #5849
Conversation
🦋 Changeset detectedLatest commit: 07d7704 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
commit: |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #5849 +/- ##
=======================================
Coverage 5.00% 5.00%
=======================================
Files 338 338
Lines 48220 48220
Branches 551 551
=======================================
Hits 2413 2413
Misses 45807 45807
Flags with carried forward coverage won't be shown. Click here to find out more. |
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
…hub.com/ReneLombard/mermaid into bug/5487-add-support-for-nested-classes
…hub.com/ReneLombard/mermaid into bug/5487-add-support-for-nested-classes
Does this support nested namespaces like i mentioned here in the examples? Nested namespaces |
This is an attempt to include nested namespaces, however, there is just a slight change in the proposed solution. Here are my thoughts. In many commercial systems, it's common to encounter deeply nested namespaces, often 4 or 5 levels deep. For example: Forexample, take the following namespace:
with POCO classes
When visualized, this structure can become bloated, as shown in the image below: By using a single box around the section, you still effectively indicate that the namespace is nested, but it ensures the boxes don't dominate or overcrowd the diagram. What are your thoughts @skillmaker-dev |
First of all Thanks for the great work you have done, I agree that the structure might become bloated, but only when there are few classes or types, which make it more visibly bloated, but in a larger codebase it's negligible It might be better to make it visible by supporting nested namespaces like this (currently not supported) : namespace A{ And what do you think about this? In this case, there would be only 2 boxes, one for the Namespace A.B and one for the nested namespace C, users can reduce the number of boxes by combining namespaces in one box ex: A.B.C which draws one box, and then the nested one ex: D which draws the nested box. namespace A.B.C{ Also is it possible to have an empty namespace? |
@skillmaker-dev For example, rather than writing: namespace CompanyA.ProductB.Endpoint.V1 { I would prefer something like: package CompanyA.ProductB.Endpoint.V1 { This approach allows for reusing a package within different class diagrams, making it possible to reference a package as a whole, rather than redrawing all the individual components each time. |
@ReneLombard wouldn't it be better to keep a consistent naming? Since package and namespace are interchangeable |
In complex software systems, where multiple class diagrams exist for a single system, it's often not practical to represent the entire architecture in one comprehensive diagram. Attempting to do so results in an overly large and convoluted diagram that offers little additional value. Instead, the focus should be on the subsystem you are currently designing. This is where the logical separation between packages and namespaces becomes particularly advantageous. If we consider other modeling tools like Enterprise Architect, the concept of a package is far from new and has long been established. Similarly, in software languages like .NET, the idea of packages is quite evident through the NuGet package manager. A NuGet package can encompass one or more packages, which in turn may bundle multiple namespaces. These namespaces contain classes that are eventually compiled into a single DLL, demonstrating the logical bundling of related functionalities. Upon further reflection, it becomes increasingly clear that both packages and namespaces play equally important roles. You should have the flexibility to encapsulate a namespace within another namespace, just as a package can contain multiple namespaces. For reference, IBM's definition of UML Class Diagrams explicitly incorporates the concepts of both packages and namespaces: I think it is valuable to create a separate issue on this matter to further investigate this, either way, i think it is still beneficial to be able to create dots in namespaces. |
@ReneLombard are correct, This should be in a separate issue where more feedback is required from the community, and yes what you have done is valuable, it's good to have the possibility to include dots in namespace names. @jgreywolf @sidharthv96 @knsv what do you guys think about this? |
If there's any chance it could be reviewed and merged soon, I would greatly appreciate it. |
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.
LGTM!
Can you please add a visual test in cypress/integration/rendering/classDiagram-v2.spec.js
…hub.com/ReneLombard/mermaid into bug/5487-add-support-for-nested-classes
@ReneLombard, Thank you for the contribution! |
📑 Summary
Resolves #5487
📏 Design Decisions
Updated the jison to support dots in the classnames and namespaces
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.