diff options
author | lain <lain@soykaf.club> | 2019-09-13 16:31:27 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-09-13 16:31:27 +0200 |
commit | a7f31bf06cfe3f8e2549393f34d6573854d783c0 (patch) | |
tree | f53d6747ee73044f7b342d3fdae3d30b5b5b3c90 /lib/mix/tasks/pleroma/docs.ex | |
parent | f649a2e972b70dfefb7bfc110b27a0194cda51c5 (diff) | |
parent | 0d9609894f4f4557da2db62a33da1b8995c9e1d7 (diff) | |
download | pleroma-a7f31bf06cfe3f8e2549393f34d6573854d783c0.tar.gz |
Merge remote-tracking branch 'origin/develop' into reactions
Diffstat (limited to 'lib/mix/tasks/pleroma/docs.ex')
-rw-r--r-- | lib/mix/tasks/pleroma/docs.ex | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/mix/tasks/pleroma/docs.ex b/lib/mix/tasks/pleroma/docs.ex new file mode 100644 index 000000000..0d2663648 --- /dev/null +++ b/lib/mix/tasks/pleroma/docs.ex @@ -0,0 +1,42 @@ +defmodule Mix.Tasks.Pleroma.Docs do + use Mix.Task + import Mix.Pleroma + + @shortdoc "Generates docs from descriptions.exs" + @moduledoc """ + Generates docs from `descriptions.exs`. + + Supports two formats: `markdown` and `json`. + + ## Generate Markdown docs + + `mix pleroma.docs` + + ## Generate JSON docs + + `mix pleroma.docs json` + """ + + def run(["json"]) do + do_run(Pleroma.Docs.JSON) + end + + def run(_) do + do_run(Pleroma.Docs.Markdown) + end + + defp do_run(implementation) do + start_pleroma() + + with {descriptions, _paths} <- Mix.Config.eval!("config/description.exs"), + {:ok, file_path} <- + Pleroma.Docs.Generator.process( + implementation, + descriptions[:pleroma][:config_description] + ) do + type = if implementation == Pleroma.Docs.Markdown, do: "Markdown", else: "JSON" + + Mix.shell().info([:green, "#{type} docs successfully generated to #{file_path}."]) + end + end +end |