Add missing Copyright headers
[akkoma] / lib / mix / tasks / pleroma / docs.ex
index d68e02383158fb67f5f780d2121eb86c3b1b9873..ad5c37fc9b7ffb47b17d315a8ae078798102ceb8 100644 (file)
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Mix.Tasks.Pleroma.Docs do
   use Mix.Task
   import Mix.Pleroma
@@ -8,13 +12,13 @@ defmodule Mix.Tasks.Pleroma.Docs do
 
   Supports two formats: `markdown` and `json`.
 
-  ## Generate markdown docs
+  ## Generate Markdown docs
 
   `mix pleroma.docs`
 
-  ## Generate json docs
+  ## Generate JSON docs
 
-  `mix pleroma.docs json`s
+  `mix pleroma.docs json`
   """
 
   def run(["json"]) do
@@ -27,14 +31,16 @@ defmodule Mix.Tasks.Pleroma.Docs do
 
   defp do_run(implementation) do
     start_pleroma()
-    {descriptions, _paths} = Mix.Config.eval!("config/description.exs")
 
-    {:ok, file_path} =
-      Pleroma.Docs.Formatter.process(
-        implementation,
-        descriptions[:pleroma][:config_description]
-      )
+    with descriptions <- Pleroma.Config.Loader.read("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, "Markdown docs successfully generated to #{file_path}."])
+      Mix.shell().info([:green, "#{type} docs successfully generated to #{file_path}."])
+    end
   end
 end