Exdot (exdot v0.1.0) View Source

Elixir abstraction generate Graphviz dot formatted string.

Block Constructs

Block constructs takes an optional name and set of expressions to return dot formatted string. Each expression inside the block is converted to dot format statement.

Valid expressions within the block

  • Two element list. If second element is a list, it is treated as attr list
[:graph, [rankdir: "LR", labeljust: "jleft"]]  # => graph [ rankdir = "LR" labeljust = "jleft" ]
["node", [shape: "plaintext"]]  # => node [ shape = "plaintext" ]
[:ranksep, "2"]  # => raksep = "2"

It can also be single pair keyword list. It is treated same as 2 element list

[graph: [rankdir: "LR", labeljust: "jleft"]]  # => graph [ rankdir = "LR" labeljust = "jleft" ]
["node" => [shape: "plaintext"]]  # => graph [ rankdir = "LR" labeljust = "jleft" ]
[ranksep: "2"]  # => ranksep = "2"
  • String. A String expression is emmitted as it is, this can used as an escape hatch to return any dot statements for which there is not special synatx, like edge.
"Company:emp_name -> Employee:name [ style = \"dashed\" ]" # => Company:emp_name -> Employee:name [ style = "dashed" ]
  • Function call. Function must return any of the above valid values. This can be used as an abstraction to build high-level syntax or templates. See Exdot.ERD
defmodule Graph do
  def edge(a, b), do: a <> " -> " <> b
end

digraph do
  ["Company", [label: "Company"]]
  ["Employee", [label: "Employee"]]

  Graph.edge("Company", "Employee")
end

Link to this section Summary

Functions

Returns digraph formatted string.

Returns graph formatted string.

Returns subgraph formatted string.

Link to this section Types

Specs

expr() ::
  String.t()
  | [{name :: atom() | String.t(), value :: keyword() | String.t()}]
  | nonempty_improper_list(
      name :: atom() | String.t(),
      value :: keyword() | String.t()
    )
  | (... -> expr())

Link to this section Functions

Link to this macro

digraph(label \\ "", list)

View Source (macro)

Specs

digraph(String.t(), do_block :: [expr()]) :: String.t()

Returns digraph formatted string.

See module documentation for more details

Link to this macro

graph(label \\ "", list)

View Source (macro)

Specs

graph(String.t(), do_block :: [expr()]) :: String.t()

Returns graph formatted string.

See module documentation for more details

Link to this macro

subgraph(label \\ "", list)

View Source (macro)

Specs

subgraph(String.t(), do_block :: [expr()]) :: String.t()

Returns subgraph formatted string.

See module documentation for more details