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

Nested generics on ClassDiagram #4937

Open
nicanor-busto opened this issue Oct 10, 2023 · 5 comments
Open

Nested generics on ClassDiagram #4937

nicanor-busto opened this issue Oct 10, 2023 · 5 comments
Assignees
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@nicanor-busto
Copy link

nicanor-busto commented Oct 10, 2023

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

@nicanor-busto nicanor-busto added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Oct 10, 2023
@erichiller
Copy link

erichiller commented Oct 14, 2023

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
  • Broken on v10.5.0 (using the LiveEditor), renders as:
    + Dictionary~KeyType,List~ElType~> Dict

  • Errors on v10.4.0 with Syntax error in text

  • Broken on whatever version GitHub uses with Maximum call stack size exceeded

  • Works great on v9.2.2
    + 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
}
Loading

vs.

classDiagram

class ChartViewModel {
    + Dictionary~KeyType,List~ElType~~ Dict
}
Loading

@immortal-boy
Copy link

It could write like this doSomething() Either&lt;List&lt;Foo&gt;,Pojo&gt; now

@jgreywolf jgreywolf added include roadmap items to add to roadmap for auto workflow and removed include roadmap items to add to roadmap for auto workflow labels Nov 16, 2023
@jgreywolf jgreywolf self-assigned this Dec 6, 2023
@jgreywolf
Copy link
Contributor

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

sidrus commented Jan 8, 2024

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

5 participants