1 defmodule Pleroma.Docs.Markdown do
2 @behaviour Pleroma.Docs.Formatter
4 def process(descriptions) do
5 config_path = "docs/config.md"
6 {:ok, file} = File.open(config_path, [:write])
7 IO.write(file, "# Generated configuration\r\n\r\n")
8 IO.write(file, "Date of generation: #{Date.utc_today()}\r\n\r\n")
12 "This file describe the configuration, it is recommended to edit the relevant *.secret.exs file instead of the others founds in the ``config`` directory.
13 If you run Pleroma with ``MIX_ENV=prod`` the file is ``prod.secret.exs``, otherwise it is ``dev.secret.exs``.\r\n\r\n"
16 for group <- descriptions do
17 if is_nil(group[:key]) do
18 IO.write(file, "## #{inspect(group[:group])}\r\n\r\n")
20 IO.write(file, "## #{inspect(group[:key])}\r\n\r\n")
23 IO.write(file, "Type: `#{group[:type]}` \r\n")
24 IO.write(file, "#{group[:description]} \r\n\r\n")
26 for child <- group[:children] do
27 print_child_header(file, child)
29 print_suggestions(file, child[:suggestions])
31 if child[:children] do
32 for subchild <- child[:children] do
33 print_child_header(file, subchild)
35 print_suggestions(file, subchild[:suggestions])
40 IO.write(file, "\r\n")
43 :ok = File.close(file)
47 defp print_suggestion(file, suggestion) when is_function(suggestion) do
48 IO.write(file, " `#{inspect(suggestion.())}`\r\n")
51 defp print_suggestion(file, suggestion) do
52 IO.write(file, " `#{inspect(suggestion)}`\r\n")
55 defp print_suggestions(file, suggestions) do
56 IO.write(file, "Suggestions: \r\n")
58 for suggestion <- suggestions do
59 print_suggestion(file, suggestion)
63 defp print_child_header(file, child) do
64 IO.write(file, "* `#{inspect(child[:key])}`: #{child[:description]} \r\n")
65 IO.write(file, "Type: `#{inspect(child[:type])}` \r\n")