some clean up
[akkoma] / lib / mix / tasks / pleroma / docs.ex
1 defmodule Mix.Tasks.Pleroma.Docs do
2 use Mix.Task
3 import Mix.Pleroma
4
5 @shortdoc "Generates docs from descriptions.exs"
6 @moduledoc """
7 Generates docs from `descriptions.exs`.
8
9 Supports two formats: `markdown` and `json`.
10
11 ## Generate Markdown docs
12
13 `mix pleroma.docs`
14
15 ## Generate JSON docs
16
17 `mix pleroma.docs json`
18 """
19
20 def run(["json"]) do
21 do_run(Pleroma.Docs.JSON)
22 end
23
24 def run(_) do
25 do_run(Pleroma.Docs.Markdown)
26 end
27
28 defp do_run(implementation) do
29 start_pleroma()
30
31 with descriptions <- Pleroma.Config.Loader.load("config/description.exs"),
32 {:ok, file_path} <-
33 Pleroma.Docs.Generator.process(
34 implementation,
35 descriptions[:pleroma][:config_description]
36 ) do
37 type = if implementation == Pleroma.Docs.Markdown, do: "Markdown", else: "JSON"
38
39 Mix.shell().info([:green, "#{type} docs successfully generated to #{file_path}."])
40 end
41 end
42 end