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.79k stars 6.65k forks source link

Link declaration depends on other declarations #2234

Open wouterbeek opened 3 years ago

wouterbeek commented 3 years ago

Describe the bug When a link declaration contains a class name that has not appeared before, Mermaid does not render the class. It also does not emit an error or warning.

To Reproduce Steps to reproduce the behavior:

  1. Create a class diagram with a link declaration for a class that does not appear anywhere else in the same Mermaid snippet.
  2. Generate the Mermaid diagram and notice that the class is not generated at all. Also notice that there are no errors or warnings.

Expected behavior Either:

  1. An error message explaining that link declarations are only valid if their corresponding classes are declared separately (e.g. in a class declaration), plus inclusion of the dependency between link declarations and other declarations in the documentation, or
  2. The existence of the class to be deduced from the link declaration.

I personally prefer variant (2) because it keeps the language and documentation simple. If declarations interact with one another in unnecessary ways this makes writing Mermaid diagrams more complex.

Code Sample The following snippet renders an empty diagram:

classDiagram
  link Animal "./#Animal"

The following snippet renders the intended diagram:

classDiagram
  class Animal
  link Animal "./#Animal"

Desktop:

jgreywolf commented 1 month 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 :)