Protocol implemented by every Beancount directive struct.
A directive knows how to render itself into a fragment of valid Beancount
text via to_bean/1. The top-level Beancount.Renderer is responsible for
joining individual directive fragments into a complete .bean document.
Directive structs
Each module under Beancount.Directives documents its Beancount syntax,
Elixir struct shape, and fields. See the
Beancount language syntax.
Beancount.Directives.Open—openBeancount.Directives.Close—closeBeancount.Directives.Commodity—commodityBeancount.Directives.Transaction—*/txntransactionsBeancount.Directives.Posting— transaction legsBeancount.Directives.Balance—balanceBeancount.Directives.Pad—padBeancount.Directives.Note—noteBeancount.Directives.Document—documentBeancount.Directives.Price—priceBeancount.Directives.Event—eventBeancount.Directives.Query—queryBeancount.Directives.Custom—customBeancount.Directives.Option—optionBeancount.Directives.Include—includeBeancount.Directives.Plugin—pluginBeancount.Directives.PushTag—pushtagBeancount.Directives.PopTag—poptag
Prefer Beancount.open/4, Beancount.transaction/6, and the other
constructor functions in Beancount when building ledgers programmatically.
Summary
Types
Any value implementing the Beancount.Directive protocol.
Functions
Render a single directive into Beancount text.
Types
@type t() :: term()
Any value implementing the Beancount.Directive protocol.
Functions
Render a single directive into Beancount text.
The returned value is iodata/0 without a trailing newline. The renderer
takes care of separating directives.
Examples
iex> open = Beancount.open(~D[2026-01-01], "Assets:Bank", ["USD"])
iex> open |> Beancount.Directive.to_bean() |> IO.iodata_to_binary()
"2026-01-01 open Assets:Bank USD"