mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
72.59k stars 6.62k forks source link

Nested generics on ClassDiagram #4937

Open nicanor-busto opened 1 year ago

nicanor-busto commented 1 year ago

Description

Hi, I've not found an issue about it, but if I put nested generic types on method return type they're represented in a wrong way, for example:

This:

classDiagram
    direction TB

    class Foo {
        + doSomething() Either~List~Foo~,Pojo~
    }

Returns something like: mermaid-diagram-2023-10-10-161002

Which is incorrect.

Steps to reproduce

Create a data type with two generics, one of them must have a generic type as well.

Code Sample

erichiller commented 1 year ago

I think I'm having the same issue, but if not let me know I can create a different issue.

Defining a property in classDiagram that has two Generic Type parameters, such as:

+ Dictionary~KeyType,List~ElType~~ Dict

It appears it is the comma breaking things, as this works:

                    ↓ no comma works
+ Dictionary~KeyType->List~ElType~~ Dict

Here is a full sample:

classDiagram

class ChartViewModel {
    + Dictionary~KeyType->List~ElType~~ Dict
}

vs.

classDiagram

class ChartViewModel {
    + Dictionary~KeyType,List~ElType~~ Dict
}
immortal-boy commented 1 year ago

It could write like this doSomething() Either<List<Foo>,Pojo> now

jgreywolf commented 11 months ago

@erichiller is correct (missed the comment somehow) - this is due to the commas, and something I am, slowly, in the process of working on.

sidrus commented 10 months ago

I would like to offer my workaround for this. I just used the #44; HTML entity for the comma:

class OrderBook {
    -Dictionary ~decimal#44; Queue~Order~~ BuyQueue
    -Dictionary ~decimal#44; Queue~Order~~ SellQueue
    +AddOrder() void       
}

That resulted in this output: image

jgreywolf commented 3 weeks ago

I am sorry for the LONG delay - but I am now actively working on an update to the class diagram syntax that will address this, and other, issues.

Should have something within a couple of days :)