giant massive dep upgrade and dialyxir-found error emporium (#371)
[akkoma] / lib / mix / tasks / pleroma / docs.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Mix.Tasks.Pleroma.Docs do
6 use Mix.Task
7 import Mix.Pleroma
8
9 @shortdoc "Generates docs from descriptions.exs"
10 @moduledoc """
11 Generates docs from `descriptions.exs`.
12
13 Supports two formats: `markdown` and `json`.
14
15 ## Generate Markdown docs
16
17 `mix pleroma.docs`
18
19 ## Generate JSON docs
20
21 `mix pleroma.docs json`
22 """
23
24 def run(["json"]) do
25 do_run(Pleroma.Docs.JSON)
26 end
27
28 def run(_) do
29 do_run(Pleroma.Docs.Markdown)
30 end
31
32 defp do_run(implementation) do
33 start_pleroma()
34
35 with descriptions <- Pleroma.Config.Loader.read("config/description.exs"),
36 {:ok, file_path} <-
37 Pleroma.Docs.Generator.process(
38 implementation,
39 descriptions[:pleroma][:config_description]
40 ) do
41 type = if implementation == Pleroma.Docs.Markdown, do: "Markdown", else: "JSON"
42
43 Mix.shell().info([:green, "#{type} docs successfully generated to #{file_path}."])
44 end
45 end
46 end