Inspect.Algebra.format
You're seeing just the function
format
, go back to Inspect.Algebra module for more information.
Specs
format(t(), non_neg_integer() | :infinity) :: iodata()
Formats a given document for a given width.
Takes the maximum width and a document to print as its arguments and returns an IO data representation of the best layout for the document to fit in the given width.
The document starts flat (without breaks) until a group is found.
Examples
iex> doc = Inspect.Algebra.glue("hello", " ", "world")
iex> doc = Inspect.Algebra.group(doc)
iex> doc |> Inspect.Algebra.format(30) |> IO.iodata_to_binary()
"hello world"
iex> doc |> Inspect.Algebra.format(10) |> IO.iodata_to_binary()
"hello\nworld"