Erl2ex v0.0.9 Erl2ex
Erl2ex is an Erlang to Elixir transpiler, converting well-formed Erlang source to Elixir source with equivalent functionality.
The goal is to produce correct, functioning Elixir code, but not necessarily perfectly idiomatic. This tool may be used as a starting point when porting code from Erlang to Elixir, but manual cleanup will likely be desired.
This module provides the main entry points into Erl2ex.
Summary
Types
A file identifier, which may be a filesystem path or a symbolic id
Options that may be provided to a conversion run
Functions
Given a source and a sink, and the source path for one Erlang source file, converts to Elixir and writes the result to the sink at the given destination path. Writes the result to the given results collector. Returns :ok
Searches a directory for Erlang source files, and writes corresponding Elixir files for each module
Converts a single Erlang source file, and writes the generated Elixir code to a new file
Converts the source for an Erlang module, represented as a string
Converts the source for an Erlang module, represented as a string, and returns the Elixir source as a string
Types
options :: [include_dir: Path.t, lib_dir: {atom, Path.t} | %{atom => Path.t}, define_prefix: String.t, defines_from_config: atom, emit_file_headers: boolean, verbosity: integer]
Options that may be provided to a conversion run.
Recognized options are:
:include_dir
Add a directory to the include path.:lib_dir
Specifies the directory for a named application.:define_prefix
Prefix added to the environment variable or config key names that are read to initialize macro definitions. Default: “DEFINE_”.:defines_from_config
An application whose config should be used to initialize macro definitions. If not specified or set to nil, system environment variables will be used.:emit_file_headers
Add a header comment to each file. Default is true.:verbosity
Set the output verbosity level. (Default is 0, which outputs only error messages. 1 outputs basic status information, and 2 outputs debug information.)
Functions
Specs
convert(Erl2ex.Source.t, Erl2ex.Sink.t, Erl2ex.Results.Collector.t, Erl2ex.file_id, Erl2ex.file_id, options) :: :ok
Given a source and a sink, and the source path for one Erlang source file, converts to Elixir and writes the result to the sink at the given destination path. Writes the result to the given results collector. Returns :ok.
Specs
convert_dir(Path.t, Path.t | nil, options) :: Erl2ex.Results.t
Searches a directory for Erlang source files, and writes corresponding Elixir files for each module.
By default, the Elixir files will be written in the same directories as the Erlang source files. You may optionally provide a different base directory for the destination files.
Returns a results object.
Specs
convert_file(Path.t, Path.t | nil, options) :: Erl2ex.Results.t
Converts a single Erlang source file, and writes the generated Elixir code to a new file.
You must provide the relative or absolute path to the Erlang source. You may optionally provide a path to the Elixir destination. If the destination is not specified, the result will be written in the same directory as the source.
Returns a results object.
Specs
Converts the source for an Erlang module, represented as a string.
If the conversion is successful, returns a tuple of {:ok, result}. If an error occurs, returns a tuple of {:error, error_details}.