scribe v0.9.0 Scribe View Source

Pretty-print tables of structs and maps

Link to this section Summary

Types

Options for configuring table output

Functions

Enables/disables auto-inspect override

Returns true if Scribe is overriding Inspect

Formats data into a printable table string

Prints a table from given data and returns the data

Prints a table from given data

Link to this section Types

Link to this type

data() View Source
data() :: [] | [...] | term()

Link to this type

format_opts() View Source
format_opts() :: [
  colorize: boolean(),
  data: [...],
  style: module(),
  width: integer()
]

Options for configuring table output.

  • :colorize - When false, disables colored output. Defaults to true
  • :data - Defines table headers
  • :style - Style callback module. Defaults to Scribe.Style.Default
  • :width - Defines table width. Defaults to :infinite

Link to this section Functions

Link to this function

auto_inspect(inspect?) View Source
auto_inspect(boolean()) :: :ok

Enables/disables auto-inspect override.

If true, Scribe will override inspect/2 for maps and structs, printing them as tables.

Examples

iex> Scribe.auto_inspect(true)
:ok

Returns true if Scribe is overriding Inspect.

Examples

iex> Scribe.auto_inspect?
true
Link to this function

console(results, opts \\ []) View Source

Link to this function

format(results, opts \\ []) View Source

Formats data into a printable table string.

Examples

iex> format([])
:ok

iex> format(%{test: 1234}, colorize: false)
"+---------+\n| :test   |\n+---------+\n| 1234    |\n+---------+\n"
Link to this function

inspect(results, opts \\ []) View Source
inspect(term(), format_opts()) :: term()

Prints a table from given data and returns the data.

Useful for inspecting pipe chains.

Examples

iex> Scribe.inspect([])
[]

iex> Scribe.inspect(%{key: :value, test: 1234}, colorize: false)
+----------+---------+
| :key     | :test   |
+----------+---------+
| :value   | 1234    |
+----------+---------+
%{test: 1234, key: :value}
Link to this function

print(results, opts \\ []) View Source
print(data(), format_opts()) :: :ok

Prints a table from given data.

Examples

iex> print([])
:ok

iex> Scribe.print(%{key: :value, test: 1234}, colorize: false)
+----------+---------+
| :key     | :test   |
+----------+---------+
| :value   | 1234    |
+----------+---------+
:ok