2020-10-12 11:00:50 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-12 23:49:20 -07:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-10-12 11:00:50 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
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
|
|
|
|
2019-08-30 10:59:13 -06:00
|
|
|
`mix pleroma.docs json`
|
2019-08-30 04:22:21 -06:00
|
|
|
"""
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
2020-03-11 07:25:53 -06:00
|
|
|
with descriptions <- Pleroma.Config.Loader.read("config/description.exs"),
|
2019-09-03 11:11:32 -06:00
|
|
|
{:ok, file_path} <-
|
|
|
|
Pleroma.Docs.Generator.process(
|
|
|
|
implementation,
|
|
|
|
descriptions[:pleroma][:config_description]
|
|
|
|
) do
|
|
|
|
type = if implementation == Pleroma.Docs.Markdown, do: "Markdown", else: "JSON"
|
2019-08-30 04:22:21 -06:00
|
|
|
|
2019-09-03 11:11:32 -06:00
|
|
|
Mix.shell().info([:green, "#{type} docs successfully generated to #{file_path}."])
|
|
|
|
end
|
2019-08-30 04:22:21 -06:00
|
|
|
end
|
|
|
|
end
|