mermaid
mermaid copied to clipboard
Property strings on class diagrams
Is your feature request related to a problem? Please describe. I am trying to use property strings on class diagrams.
In standard UML, operations (methods) have the following syntax:
[visibility] name [(parameter-list)] [: return-type] [{property-string}]
However, property strings (the last element) are not currently supported by Mermaid.
For instance, the following code is marked as syntactically incorrect:
classDiagram
class MyClass{
+x(parameter) A
+y() B {property}
}
Describe the solution you'd like It would be great if Mermaid added support for these property strings.
It doesn't need to do it using curly brackets, if that inserts ambiguity in the syntax of the language. For example, using [square brackets]
seems like a viable option to me.
Describe alternatives you've considered
"quotation marks"
could also work for the implementation of property strings. I think that might be more intuitive.
Other option would be to use a similar approach to labels on relationships.
All in all, there's different possibilities for the implementation, and no clear better choice.
Additional context
The following would an example of how to render a property string:
For further context, you can read more about property strings on any UML reference textbook.
A good one is: The Unified Modeling Language User Guide; G. Booch, J. Rumbaugh, I.Jacobson; Addison-Wesley; First Edition. (Chapter 9, "operations"). Another good one is: UML Distilled; M. Fowler; Addison-Wesley; Third Edition. (chapter 3, page 44).
@ACMCMC This sure looks like a nice to have enhancement. We accept this as a valid enhancement feature t and will await a PR regarding this.