social.metadata.moe/lib/pleroma/docs/json.ex

21 lines
547 B
Elixir
Raw Normal View History

2019-08-30 19:21:48 +09:00
defmodule Pleroma.Docs.JSON do
2019-08-31 01:14:01 +09:00
@behaviour Pleroma.Docs.Generator
@spec process(keyword()) :: {:ok, String.t()}
2019-08-30 19:21:48 +09:00
def process(descriptions) do
config_path = "docs/generate_config.json"
2019-09-04 02:06:22 +09:00
2019-11-11 04:54:37 +09:00
with {:ok, file} <- File.open(config_path, [:write, :utf8]),
2019-09-04 02:06:22 +09:00
json <- generate_json(descriptions),
:ok <- IO.write(file, json),
:ok <- File.close(file) do
{:ok, config_path}
end
2019-08-30 19:21:48 +09:00
end
2019-08-31 01:14:01 +09:00
@spec generate_json([keyword()]) :: String.t()
2019-08-30 19:21:48 +09:00
def generate_json(descriptions) do
Jason.encode!(descriptions)
end
end