defmodule Mix.Tasks.Docs do use Mix.Task @shortdoc "Build docs with globally installed ex_doc to avoid conflicts" @moduledoc """ ex_doc uses earmark. This means we can't have a dependency from earmark back to ex_doc, as this would be circular. Instead, we run ex_doc from the command line. ## Prerequisite ### Install `ex_doc` as an escript on your system ( Elixir >= 1.8 needed) mix escript.install hex ex_doc ### For ASDF Provide the location of where the ex_doc escript is by means of the EX_DOC_ESCRIPT environment variable. N.B. Launch the above command form anywhere else than your `Earmark` root directory. """ def run(_) do ex_doc = System.get_env("EX_DOC_ESCRIPT") || "#{System.get_env("HOME")}/.mix/escripts/ex_doc" System.cmd("rm", ~w( -rf doc )) IO.puts ex_doc System.cmd(ex_doc, ~w( Earmark #{current_version()} _build/dev/lib/earmark/ebin -m Earmark -u https://github/pragdave/earmark.html )) end defp current_version do Earmark.Mixfile.project() |> Keyword.get(:version) end end # SPDX-License-Identifier: Apache-2.0