BlockDiag

BlockDiag is the simplest of the diagram generators: write a chain of arrows and you have a diagram. Nodes are created by being mentioned.

It is worth knowing because the same author wrote ActDiag, SeqDiag, NWDiag, PacketDiag and RackDiag, and they all share this syntax.


#What it is good at

  • Quick block diagrams where nothing needs styling.

  • Diagrams generated by a script, because the syntax is trivial to emit.

  • Documentation where a chain of steps is genuinely the whole picture.


#What it draws

Element

Syntax

Chain

a -> b -> c;

Label

a [label = "Step one"];

Group

group { b; c; }

Shape

a [shape = diamond];

Branch

a -> b; a -> c;


#A worked example

A chain, a branch and a group:

BlockDiag

The source, which you can paste into a new diagram and edit:

blockdiag {
  ingest [label = "Ingest"];
  validate [label = "Validate", shape = diamond];
  store [label = "Store"];
  reject [label = "Reject", color = "#ffdddd"];
  notify [label = "Notify"];

  ingest -> validate -> store -> notify;
  validate -> reject;

  group {
    label = "Pipeline";
    ingest; validate; store;
  }
}

#A few things that catch people out

  • Nodes do not need declaring; mentioning one in an arrow creates it.

  • Every statement ends with a semicolon, which is the most common syntax error.

  • For anything needing real layout control, D2 or Graphviz will serve you better.



Thirty-one languages. Nobody knows them all.