Macaw.Frame.TextForms.Class (macaw_frame v0.1.0)

Copy Markdown View Source

The classDiagram text form (spec/02 §11.3, spec/13 §7.3): a class diagram written as mermaid writes one, read into a layered diagram's design (Macaw.Frame.TextForms) whose nodes are compartmented: a class's name over its members.

classDiagram
  class Animal {
    +String name
    +move(int) void
  }
  Animal <|-- Duck : is a
  Duck : +swim()
  Pond *-- Duck
  Pond o.. Frog
  • A class is class Name, or class Name { with a member a line until }; Name : member adds a member; a class named only by a relation has none.
  • A relation is A <end><line><end> B, with : label after it: the line -- (solid) or .. (dashed), each end <|/|> (open, a generalization's hollow triangle), * (diamond, a composition), o (open_diamond, an aggregation), </> (arrow), or none. The left end is the edge's tail at A, the right its head at B.

Rows: nodes (id, label the name and its members a line each, shape rect, group none) in order of first appearance; edges in order; members (node, text, visibility its leading +, -, # or ~, kind method when it holds a (, else attribute) in class order, each class's in the order written. Faults, every one at once: {:expected, :class}, {:expected, :relation}, {:unclosed, "class"}, {:unexpected, "}"}. print/1 writes each class with its members, then the relations.