diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-09-14 16:11:44 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-09-14 16:11:44 +0300 |
commit | 6bcedb693c47fcef44ff3b4412629d1c50c2a1c7 (patch) | |
tree | 0420581ba993b70cb957c261cb83ef90597ddeb4 /lib/mix/tasks/pleroma/docs.ex | |
parent | c3f00447afc67b460e63b531e4f2432bfaa37bdb (diff) | |
parent | a9b78f55e3561eec3cd125f030d2dd6ec338d406 (diff) | |
download | pleroma-6bcedb693c47fcef44ff3b4412629d1c50c2a1c7.tar.gz |
[#1149] Merge remote-tracking branch 'remotes/upstream/develop' into 1149-oban-job-queue
# Conflicts:
# docs/config.md
# mix.lock
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 |