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

class diagrams: allow notes for namespace'd classes #4706

Open The-Alchemist opened 1 year ago

The-Alchemist commented 1 year ago

Proposal

Short Description

...should improve its support for notes inside namespaces.

Example Syntax

The following example shows a note for a specific class inside a namespace. This syntax currently results in a parse error, Expecting CLASS, got NOTE_FOR:


classDiagram
namespace BaseShapes {

    note for Triangle "i am a note for Triangle"
    class Triangle
    class Rectangle {
      double width
      double height
    }
}

You can play with this syntax here on the playground.

Details

Technically, you can add a note for a namespaced class, but you have to place the note outside the namespace, and therefore, it renders outside the namespace.

classDiagram
namespace BaseShapes {

    class Triangle
    class Rectangle {
      double width
      double height
    }
}
note for Triangle "i am a note for Triangle"
The above diagram doesn't render in Github's viewer, but [you can view it on the playground](https://mermaid.live/edit#pako:eNplkE1vhCAQhv8KmbMxikVcjptee-n21HCZyriSKBjFtFvjfy_STdO0k0mAZ975YoPWGwIF7YDL8mjxOuOoncORlglbYmdc6NLjRAvbtNOORUta9jJbdNeBfrNnakOCh5glM359i-93a0L_h_Vkr334hrt20Z0PxDo__xRnGizDkSH7F9KgHWQw0jyiNXGF1FJD6GmMQRWvhjpch3Ao9yjFNfjLzbWgwrxSButkMNB9aVAdDkukEzpQG3yA4mWRc1lyXgnBRf0gmgxuoEpZ57I-cVmdpKxqUco9g0_vY4kiF41oCsnrqhFlWR8ZZGzw89P9m48j9XhNCccg-xdnLnu-). It appears like this: ![image](https://github.com/mermaid-js/mermaid/assets/812287/a85c3ae6-a825-4e9e-b8f7-7621f5ec7dc1) ### Example ``` classDiagram namespace BaseShapes { note for Triangle "i am a note for Triangle" class Triangle class Rectangle { double width double height } } ``` ### Screenshots _No response_
Adarsha186 commented 4 days ago

Hi @The-Alchemist, is this issue still open, I'm interested in doing open source contributions, if this issue is open can I take up this task.

The-Alchemist commented 3 days ago

Hi @The-Alchemist, is this issue still open, I'm interested in doing open source contributions, if this issue is open can I take up this task.

I think @kairi003 is working on it, or is done. See https://github.com/mermaid-js/mermaid/pull/5814

But please don't hesitate to pick up another task!

kairi003 commented 3 days ago

@The-Alchemist Yes, the pr to resolve this issue is done. Now I am waiting for the merge, is there anything I can do for that?

jgreywolf commented 13 hours ago

I am rerunning the tests to see if we get past the timeout failure there