Packages

ExDash builds a Dash Docset with your local Elixir app.

Current section

Files

Jump to
ex_dash lib formatter.ex
Raw

lib/formatter.ex

defmodule ExDash.Formatter do
@moduledoc """
An ExDoc formatter for Dash Documentation.
"""
alias ExDash.Formatter.{Injector,Docset}
@spec run(list, ExDoc.Config.t) :: String.t
def run(project_nodes, config) when is_map(config) do
{config, docset_root_path} =
Docset.build(project_nodes, config)
ExDoc.Formatter.HTML.run(project_nodes, config)
transform_ex_docs_to_dash_docs(config.output)
docset_root_path
end
defp transform_ex_docs_to_dash_docs(output_docs_dir, ends_with \\ ".html") do
File.ls!(output_docs_dir)
|> Stream.filter(&String.ends_with?(&1, ends_with))
|> Stream.map(&Path.join(output_docs_dir, &1))
|> Enum.map(&Injector.inject_all/1)
end
end