# `Macaw.Draw.Render.Target`
[🔗](https://github.com/dcoai/macaw_draw/blob/v0.1.0/lib/macaw/draw/render/target.ex#L1)

The behavior of a rendering target (spec/10 §2.2), visualize's `Visualize.Backend`:
what `Macaw.Draw.Render.render/3` dispatches a path, a node and a list of nodes to.

Each callback answers `{:ok, output}` or `{:error, faults}`, a fault `{path, reason}`
with the path the child indexes from the root (spec/10 §2.5); a target never raises on a
scene. `wrap_root/2` is optional: a target that writes a document around a list of nodes
implements it.

# `error`

```elixir
@type error() :: {:error, [Macaw.Base.Fault.t()]}
```

A refusal: faults with their paths.

# `output`

```elixir
@type output() :: iodata() | [term()]
```

A target's output: markup, a command list, a byte stream.

# `render_node`

```elixir
@callback render_node(Macaw.Draw.IR.Element.t(), keyword()) :: {:ok, output()} | error()
```

A node and everything under it.

# `render_path`

```elixir
@callback render_path(Macaw.Draw.IR.Path.t(), keyword()) :: {:ok, output()} | error()
```

A path written alone, with the target's options.

# `render_scene`

```elixir
@callback render_scene([Macaw.Draw.IR.Element.t()], keyword()) ::
  {:ok, output()} | error()
```

A list of nodes, a whole scene.

# `wrap_root`
*optional* 

```elixir
@callback wrap_root(output(), keyword()) :: {:ok, output()} | error()
```

Written output wrapped in the target's document.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
