IEx.Info — IEx v1.16.3

Search documentation of IEx

# View Source IEx.Info protocol (IEx v1.16.3)

A protocol to print information in IEx about the given data structure.

`IEx.Helpers.i/1` uses this protocol to display a term-specific list of information.

By default, an `Any` implementation will be used which returns the `"Data type"`, `"Description"` and `"Reference modules"` sections.

# Summary

## Types

t()

All the types that implement this protocol.

## Functions

info(term)

Returns information for the given term.

# Types

Link to this type

# t()

View Source

    @type t() :: term()

All the types that implement this protocol.

# Functions

Link to this function

# info(term)

View Source

    @spec info(term()) :: [{info_name :: String.Chars.t(), info :: String.t()}]

Returns information for the given term.

Information should be returned as a list of `info_name`-`info` tuples, where `info_name` is a string-like value, such as an atom or a string itself, and `info` is a string. `info_name` should be short. `info` can be arbitrarily long and contain newlines.

`IEx.Helpers.i/1` will generate (and always display) the 'Implemented protocols' and 'Term' sections in the result.

All other sections of information are added (and can be overridden) by customized implementations of this function.

It is recommended to at least include the following sections for a custom implementation:

- `"Data type"`: Name of the data type. Usually the name of the module defining the data type.
- `"Description"`: One or a few sentences describing what the data type represents.
- `"Reference modules`: One or a few comma-separated module names that focus on working with this datatype.

Other recommended sections are:

- `"Raw representation`: showing another way of writing the passed `term`. This is mostly relevant for data-structures whose `String.Chars`-implementations make use of sigils or other syntactic sugar.