Merge branch 'develop' into feature/tag_feed
[akkoma] / lib / pleroma / docs / json.ex
1 defmodule Pleroma.Docs.JSON do
2 @behaviour Pleroma.Docs.Generator
3
4 @spec process(keyword()) :: {:ok, String.t()}
5 def process(descriptions) do
6 with path <- "docs/generated_config.json",
7 {:ok, file} <- File.open(path, [:write, :utf8]),
8 formatted_descriptions <-
9 Pleroma.Docs.Generator.convert_to_strings(descriptions),
10 json <- Jason.encode!(formatted_descriptions),
11 :ok <- IO.write(file, json),
12 :ok <- File.close(file) do
13 {:ok, path}
14 end
15 end
16
17 def compile do
18 with config <- Pleroma.Config.Loader.load("config/description.exs") do
19 config[:pleroma][:config_description]
20 |> Pleroma.Docs.Generator.convert_to_strings()
21 |> Jason.encode!()
22 end
23 end
24 end