akkoma/lib/mix/tasks/pleroma/docs.ex

41 lines
829 B
Elixir
Raw Normal View History

2019-08-30 04:22:21 -06:00
defmodule Mix.Tasks.Pleroma.Docs do
use Mix.Task
import Mix.Pleroma
@shortdoc "Generates docs from descriptions.exs"
@moduledoc """
Generates docs from `descriptions.exs`.
Supports two formats: `markdown` and `json`.
2019-08-30 10:14:01 -06:00
## Generate Markdown docs
2019-08-30 04:22:21 -06:00
`mix pleroma.docs`
2019-08-30 10:14:01 -06:00
## Generate JSON docs
2019-08-30 04:22:21 -06:00
`mix pleroma.docs json`s
"""
def run(["json"]) do
do_run(Pleroma.Docs.JSON)
end
def run(_) do
do_run(Pleroma.Docs.Markdown)
end
defp do_run(implementation) do
start_pleroma()
2019-08-30 05:27:55 -06:00
{descriptions, _paths} = Mix.Config.eval!("config/description.exs")
2019-08-30 04:22:21 -06:00
{:ok, file_path} =
2019-08-30 10:14:01 -06:00
Pleroma.Docs.Generator.process(
2019-08-30 04:22:21 -06:00
implementation,
descriptions[:pleroma][:config_description]
)
Mix.shell().info([:green, "Markdown docs successfully generated to #{file_path}."])
end
end