821ee74f95ccc4606586929a5dc8c2c2cf71dca4
[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`s
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 {descriptions, _paths} = Mix.Config.eval!("config/description.exs")
31
32 {:ok, file_path} =
33 Pleroma.Docs.Generator.process(
34 implementation,
35 descriptions[:pleroma][:config_description]
36 )
37
38 Mix.shell().info([:green, "Markdown docs successfully generated to #{file_path}."])
39 end
40 end