exfmt v0.2.0 Exfmt

Exfmt, an opinionated Elixir source code formatter. 🌸

aka The everyone’s favourite Elixir-to-Elixir compiler.

API

Functions in this module can be considered part of Exfmt’s public interface, and can be presumed stable. Functions exposed by other modules may change at any time without warning, especially before v1.0.0.

Link to this section Summary

Functions

Check that a string of source code conforms to the exfmt style. If formatting the source code would not result in the source code changing this function will return :ok

Format a string of Elixir source code

Format a string of Elixir source code, throwing an exception in the event of failure

Format a string of Elixir source code

Link to this section Functions

Link to this function check(source, max_width \\ 80)
check(String.t, integer) ::
  :ok |
  {:format_error, String.t} |
  Exfmt.SyntaxError.t

Check that a string of source code conforms to the exfmt style. If formatting the source code would not result in the source code changing this function will return :ok.

Link to this function format(source, max_width \\ 80)

Format a string of Elixir source code.

iex> format("[1,2,3]")
{:ok, "[1, 2, 3]\n"}

This function performs a check to ensure the input and output are semantically equivalent.

Link to this function format!(source, max_width \\ 80)
format!(String.t, integer) :: String.t

Format a string of Elixir source code, throwing an exception in the event of failure.

iex> format!("[1,2,3]")
"[1, 2, 3]\n"

This function performs a check to ensure the input and output are semantically equivalent.

Link to this function unsafe_format(source, max_width \\ 80)
unsafe_format(String.t, integer) :: String.t

Format a string of Elixir source code.

iex> unsafe_format("[1,2,3]")
{:ok, "[1, 2, 3]\n"}

Unlike format/2 and format!/2 this code does not compare the semantics of the input and the output, so if there is a bug in exfmt it may semantically alter your code when reformatting it.