1 defmodule Pleroma.Docs.JSON do
2 @behaviour Pleroma.Docs.Generator
3 @external_resource "config/description.exs"
4 @raw_config Pleroma.Config.Loader.read("config/description.exs")
5 @raw_descriptions @raw_config[:pleroma][:config_description]
6 @term __MODULE__.Compiled
10 :persistent_term.put(@term, Pleroma.Docs.Generator.convert_to_strings(@raw_descriptions))
13 @spec compiled_descriptions :: Map.t()
14 def compiled_descriptions do
15 :persistent_term.get(@term)
18 @spec process(keyword()) :: {:ok, String.t()}
19 def process(descriptions) do
20 with path <- "docs/generated_config.json",
21 {:ok, file} <- File.open(path, [:write, :utf8]),
22 formatted_descriptions <-
23 Pleroma.Docs.Generator.convert_to_strings(descriptions),
24 json <- Jason.encode!(formatted_descriptions),
25 :ok <- IO.write(file, json),
26 :ok <- File.close(file) do