spc-pleroma/lib/pleroma/docs/json.ex

19 lines
493 B
Elixir
Raw Normal View History

2019-08-30 10:21:48 +00:00
defmodule Pleroma.Docs.JSON do
2019-08-30 16:14:01 +00:00
@behaviour Pleroma.Docs.Generator
@spec process(keyword()) :: {:ok, String.t()}
2019-08-30 10:21:48 +00:00
def process(descriptions) do
config_path = "docs/generate_config.json"
{:ok, file} = File.open(config_path, [:write])
json = generate_json(descriptions)
IO.write(file, json)
:ok = File.close(file)
{:ok, config_path}
end
2019-08-30 16:14:01 +00:00
@spec generate_json([keyword()]) :: String.t()
2019-08-30 10:21:48 +00:00
def generate_json(descriptions) do
Jason.encode!(descriptions)
end
end