View Source Extractly.Xtra (Extractly v0.5.4)

This wraps Extractly's API by putting all messages to be logged to the Extractly.Messages module.

Its primarty use case is for Mix.Tasks.Xtra which will pass this module as a param into the EEx template.

The general idea is

Extractly.Messages.start_agent
process_input_template # which will collect messages by means of this module's API
Extractly.Messages.get_all |> emit_messages(options)

The wrapping works as follows

  def some_function(some_params) do
    case Extractly.some_function(some_params) do
      {:ok, result} -> result
      {:error, message} -> add_message_to_messages_and_return_html_comment_describing_the_error()
    end
  end

Summary

Functions

Just a delegator to Extractly.do_not_edit_warning As there can be no error condition no wrapping is needed

Wraps call to Extractly.functiondoc as described above

Wraps call to Extractly.moduledoc as described above

Wraps a call to Extractly.toc

Functions

Link to this function

do_not_edit_warning(opts \\ [])

View Source

Just a delegator to Extractly.do_not_edit_warning As there can be no error condition no wrapping is needed

iex(1)> do_not_edit_warning() "<!--\nDO NOT EDIT THIS FILE\nIt has been generated from a template by Extractly (https://github.com/RobertDober/extractly.git)\nand any changes you make in this file will most likely be lost\n-->"

Link to this function

functiondoc(name, opts \\ [])

View Source

Wraps call to Extractly.functiondoc as described above

iex(2)> functiondoc(["Support.Module2.function/0", "Support.Module1.hello/0"])
"A function\nA nice one\n\nFunctiondoc of Module1.hello\n"
Link to this function

moduledoc(name, opts \\ [])

View Source

Wraps call to Extractly.moduledoc as described above

iex(3)> moduledoc("Support.Module2")
"<!-- module Support.Module2 does not have a moduledoc -->"
Link to this function

toc(filename_or_self, opts \\ [])

View Source

Wraps a call to Extractly.toc

If a filename is provided the TOC is extracted from the filename and inserted into the document However, if :self is provided as an argument a placeholder is inserted into the document which allows the Mix task xtra to replace the placeholder with the TOC created from the very same document

iex(4)> toc(:self)
"<!---- Extractly Self TOC #{inspect %Extractly.Toc.Options{}} ---->"

iex(5)> toc("test/fixtures/toc-short.md", min_level: 2)
"- Level2 1.first\n- Level2 1.second\n  - Level3 1.second(i)"

Errors are handled with comments and output to stderr, as usual

iex(5)> toc("surelythisfiledoesnotexist.eajeza963q1hf")
"<!-- could not read from \"surelythisfiledoesnotexist.eajeza963q1hf\" -->"