GitXplorerGitXplorer
a

erlex

public
34 stars
17 forks
6 issues

Commits

List of commits on branch master.
Verified
0548765838a08583c83d72d208fde112104a3d2b

fix: Make PRs do GHA, delete Travis (#53)

aasummers committed 4 years ago
Verified
2f79a416536bcae1fca6f0dbea5a5b2318786bb2

doc: Misc. doc, README changes (#52)

kkianmeng committed 4 years ago
Verified
e320a9082536893bd57cd2dd8dd5e246e2937a0c

feat: Hex release automation on tags (#51)

aasummers committed 4 years ago
Verified
3490a2c175b295c39f4852a5183aadf1ecd69457

chore: Mix check (#50)

aasummers committed 4 years ago
Verified
32a85d664a166e78b97f93e1d24bb5a3e6067657

feat: Special case `_ => _` in struct `do_pretty_print/1` (#49)

aasummers committed 4 years ago
Verified
b1252151f93e5eb9a545788d9f09b46a7ef340f2

fix: Fix GH Actions caches (#48)

aasummers committed 4 years ago

README

The README file for this repository.

Hex version badge Hex docs badge Total download badge License badge Build status badge Code coverage badge Last Updated badge

Erlex

Convert Erlang style structs and error messages to equivalent Elixir.

Useful for pretty printing things like Dialyzer errors and Observer state. NOTE: Because this code calls the Elixir formatter, it requires Elixir 1.6+.

Documentation

Hex Docs.

Changelog

Check out the Changelog.

Installation

The package can be installed from Hex by adding erlex to your list of dependencies in mix.exs:

def deps do
  [
    {:erlex, "~> 0.2"},
  ]
end

Usage

Invoke Erlex.pretty_print/1 with the input string.

iex> str = ~S"('Elixir.Plug.Conn':t(),binary() | atom(),'Elixir.Keyword':t() | map()) -> 'Elixir.Plug.Conn':t()"
iex> Erlex.pretty_print(str)
(Plug.Conn.t(), binary() | atom(), Keyword.t() | map()) :: Plug.Conn.t()

While the lion's share of the work is done via invoking Erlex.pretty_print/1, other higher order functions exist for further formatting certain messages by running through the Elixir formatter. Because we know the previous example is a type, we can invoke the Erlex.pretty_print_contract/1 function, which would format that appropriately for very long lines.

iex> str = ~S"('Elixir.Plug.Conn':t(),binary() | atom(),'Elixir.Keyword':t() | map(), map() | atom(), non_neg_integer(), binary(), binary(), binary(), binary(), binary()) -> 'Elixir.Plug.Conn':t()"
iex> Erlex.pretty_print_contract(str)
(
  Plug.Conn.t(),
  binary() | atom(),
  Keyword.t() | map(),
  map() | atom(),
  non_neg_integer(),
  binary(),
  binary(),
  binary(),
  binary(),
  binary()
) :: Plug.Conn.t()

Contributing

We welcome contributions of all kinds! To get started, click here.

Code of Conduct

Be sure to read and follow the code of conduct.