aboutsummaryrefslogtreecommitdiff
path: root/lib/mix
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-09-13 19:42:53 +0300
committerrinpatch <rinpatch@sdf.org>2019-09-13 19:42:53 +0300
commitba70a8cae6c0d00963dc1d9e80f915186397ad06 (patch)
treed0cfb4e9b6c8771b84f38b9d6175b47fbf4e442d /lib/mix
parentac4a748fad34c02647bf72e802cd9d74205681fe (diff)
parent53a3ad60435d4f7eab2dbf1235e5974bac275aa0 (diff)
downloadpleroma-ba70a8cae6c0d00963dc1d9e80f915186397ad06.tar.gz
Merge branch 'develop' into feature/delivery-tracking
Diffstat (limited to 'lib/mix')
-rw-r--r--lib/mix/tasks/pleroma/docs.ex42
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