Merlive

Class diagrams

A class is a box that lists its attributes and its methods under its name. Held to the same measure, and to the rows each box lists and what each link ends in.

Declared with classDiagram. Of 36 features Mermaid documents for a class diagram, 28 drawn as written, 8 drawn less something. See all 36 drawn both ways, or draw one yourself.

Mermaid
Class diagram, as Mermaid draws it
Merlive
Class diagram, as Merlive draws it

What is read

classDiagram and classDiagram-v2 are read into the same boxes and links as a flowchart, so everything else on this page holds for them: the rules, the design, Merlive's own lines.

WrittenRead as
class Order, or a name first met in a relationA class: a box named by its name
class Order["A purchase order"], class `Purchase order!`A class with a label, or with a name no bare name could be. In Merlive's own lines it is the name without the backticks
class Basket~Item~A class called Basket<Item>. What it is generic over is no part of its name: relations and Merlive's own lines say Basket
Order : +String number, class Order { +String number … }A member: one row of the box. Rows that end in brackets are what the class does and come second; the rest are what it holds and come first. A class that only holds, or only does, has one compartment
+, -, #, ~ before a member; total() MoneyKept as written: who may see the member, and what it gives back
List~Item~, List~List~Item~~ in a memberList<Item>, List<List<Item>>
check()*, total() Money*, count()$, String prefix$The row ends in the words {abstract} or {static}
class Payable <<interface>>, <<interface>> Payable, <<interface>> inside the bracketsWhat the class is, over its name: «interface»
Document <|-- Order, Order --|> DocumentInheritance: a link with a triangle at the parent. It is drawn from the parent down to the child, whichever way it was written
Payable <|.. Invoice, Invoice ..|> PayableRealisation: the same, dotted
Order *-- OrderLine, Warehouse o-- ProductComposition and aggregation: a filled or an open diamond at the class that holds
Invoice --> Order, Order ..> PriceListAssociation and dependency: an arrow, on a solid or a dotted line
Supplier -- Contact, Buyer .. NoteA link with nothing at either end
Supplier <--> Buyer, Bundle *--o ProductA relation that says something at both ends
Order "1" *-- "1..*" OrderLine : holdsHow many, beside each end, and the words on the link
Payable ()-- Invoice, Order --() PrintableA lollipop: a small box of its own for each class that offers it, named for the interface, marked «interface», with a circle on its line. In Merlive's own lines it is Invoice_Payable
namespace Buying { … }, namespace Auth["Signing in"] { … }A group of the classes declared in it, called by its label when it has one
A namespace inside another, namespace Shop.Ordering.Buying { … }A group inside a group. A dotted name makes every group it spells out, each once, called by its last word; in Merlive's own lines a group is its whole dotted name
note for Order "words", note "words"A note drawn on the picture: a sheet with a folded corner, joined to its class by a dotted line, or to nothing. A \n or <br> in it is a new line. It is as tall as its words need
classDef, cssClass "Order,Invoice" late, Order:::late, style Order …Kinds and outlines, as in a flowchart
click, link, callbackRead past

Not read yet, each named in a note, line when met: a direction other than top to bottom (direction LR), since boxes of different heights are only placed that way for now; a lollipop at both ends of one line. A line that is none of the above is said with its line number and nothing is drawn from it.

Feature by feature

Every feature Mermaid’s own pages set out for a class diagram, each with a sample of it in the corpus. A sample is drawn when every box, link and word it has is read and every rule passes. Drawn, less something is the same with one thing known to be missing, named beside it.

FeatureResultWhat is missing
A class, declared with "class"Drawn
Two classes made by tying one to the otherDrawn
A class diagram, declared with "classDiagram-v2"Drawn
A title in front matterDrawn
A class with a labelDrawn
A class named between backticksDrawn
Members given one at a time, after a colonDrawn
Members given together, between bracketsDrawn
What a method gives backDrawn
Generic types, in a class, a member and what a method gives backDrawn
Who may see a member: public, private, protected, packageDrawn
Members marked abstract or staticDrawn, less somethingAbstract and static are said in words at the end of the row, where Mermaid slants or underlines it
The eight relationsDrawn
The eight relations written the other way round, each with wordsDrawn, less something"Is a" is drawn from the parent down to the child, whichever way it was written
Words on a relationDrawn
A relation that says something at both endsDrawn
A lollipop interfaceDrawn, less somethingA lollipop is drawn as a box of its own, named for the interface and marked «interface», with the circle on its line
How many, at either end of a relationDrawn
A namespaceDrawn
A namespace with a labelDrawn
A namespace written inside anotherDrawn
Namespaces inside one another, spelt with dotsDrawn
An annotation, on the line that declares the classDrawn
An annotation, on a line of its ownDrawn
An annotation, inside the classDrawn
A comment on a line of its ownDrawn
A direction for the whole diagramDrawn, less somethingDrawn top to bottom: boxes of different heights are only placed that way yet
A class that opens a link or calls a function when clickedDrawn, less somethingThe clicks are left out: a page of Merlive opens no links and runs no code of yours
A note for a classDrawn
A note for no class in particularDrawn
A class styled on its ownDrawn, less somethingEach outline is heavy or broken as written, in the design's own nearest colour; the fill is the design's
A style class made with classDef and given with cssClassDrawn
A style class given with :::Drawn
A default style class for every classDrawn, less somethingThe default class is read past: the look is the design's
A style class kept in the page's own stylesheetDrawn, less somethingA page's own stylesheet cannot be read from here: the class is of that kind, in the design's plain look
A whole diagram: classes, what they list, what they inherit, and a noteDrawn

Written from skills/merlive/reference.md in the repository, so the two cannot disagree.

Before: State diagramsNext: Entity diagrams