Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1KB

  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. defmodule Mix.Tasks.Pleroma.Docs do
  5. use Mix.Task
  6. import Mix.Pleroma
  7. @shortdoc "Generates docs from descriptions.exs"
  8. @moduledoc """
  9. Generates docs from `descriptions.exs`.
  10. Supports two formats: `markdown` and `json`.
  11. ## Generate Markdown docs
  12. `mix pleroma.docs`
  13. ## Generate JSON docs
  14. `mix pleroma.docs json`
  15. """
  16. def run(["json"]) do
  17. do_run(Pleroma.Docs.JSON)
  18. end
  19. def run(_) do
  20. do_run(Pleroma.Docs.Markdown)
  21. end
  22. defp do_run(implementation) do
  23. start_pleroma()
  24. with descriptions <- Pleroma.Config.Loader.read("config/description.exs"),
  25. {:ok, file_path} <-
  26. Pleroma.Docs.Generator.process(
  27. implementation,
  28. descriptions[:pleroma][:config_description]
  29. ) do
  30. type = if implementation == Pleroma.Docs.Markdown, do: "Markdown", else: "JSON"
  31. Mix.shell().info([:green, "#{type} docs successfully generated to #{file_path}."])
  32. end
  33. end
  34. end