exfmt v0.2.2 Exfmt.Comment
We leverage Code.string_to_quoted/2
to get the AST from
Elixir source code. This is great as it’s maintained by
the core team (i.e. not me). This is not great as it doesn’t
preserve comments, so we need to extract them ourselves and
then merge them into the AST later.
Link to this section Summary
Functions
Extract comments from a string of Elixir source code
Merge the given comments into an Elixir abstract syntax tree
Link to this section Types
Link to this section Functions
Extract comments from a string of Elixir source code.
Merge the given comments into an Elixir abstract syntax tree.
iex> comments = [{:"#", [line: 1], []}]
...> ast = {:ok, [line: 1], []}
...> merge(comments, ast)
{:"#comment_block", [], [{:ok, [line: 1], []}, {:"#", [line: 1], []}]}