aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/docs/markdown.ex
diff options
context:
space:
mode:
authorAlex S <alex.strizhakov@gmail.com>2019-08-30 19:14:01 +0300
committerAlex S <alex.strizhakov@gmail.com>2019-09-11 09:25:33 +0300
commit6721301086674afe721f9eea478a2037756be93c (patch)
tree69788f502c367bdec3a110cff29b7a84d893de68 /lib/pleroma/docs/markdown.ex
parent0559c82bdb39cba019099d404723f38fed6e2aba (diff)
downloadpleroma-6721301086674afe721f9eea478a2037756be93c.tar.gz
some changes
Diffstat (limited to 'lib/pleroma/docs/markdown.ex')
-rw-r--r--lib/pleroma/docs/markdown.ex36
1 files changed, 24 insertions, 12 deletions
diff --git a/lib/pleroma/docs/markdown.ex b/lib/pleroma/docs/markdown.ex
index 27a096631..c66640bf1 100644
--- a/lib/pleroma/docs/markdown.ex
+++ b/lib/pleroma/docs/markdown.ex
@@ -1,16 +1,17 @@
defmodule Pleroma.Docs.Markdown do
- @behaviour Pleroma.Docs.Formatter
+ @behaviour Pleroma.Docs.Generator
+ @spec process(keyword()) :: {:ok, String.t()}
def process(descriptions) do
config_path = "docs/config.md"
{:ok, file} = File.open(config_path, [:write])
- IO.write(file, "# Generated configuration\r\n\r\n")
+ IO.write(file, "# Configuration\r\n\r\n")
IO.write(file, "Date of generation: #{Date.utc_today()}\r\n\r\n")
IO.write(
file,
- "This file describe the configuration, it is recommended to edit the relevant *.secret.exs file instead of the others founds in the ``config`` directory.
-If you run Pleroma with ``MIX_ENV=prod`` the file is ``prod.secret.exs``, otherwise it is ``dev.secret.exs``.\r\n\r\n"
+ "This file describe the configuration, it is recommended to edit the relevant `*.secret.exs` file instead of the others founds in the ``config`` directory. \r\n
+ If you run Pleroma with ``MIX_ENV=prod`` the file is ``prod.secret.exs``, otherwise it is ``dev.secret.exs``.\r\n\r\n"
)
for group <- descriptions do
@@ -20,7 +21,6 @@ If you run Pleroma with ``MIX_ENV=prod`` the file is ``prod.secret.exs``, otherw
IO.write(file, "## #{inspect(group[:key])}\r\n\r\n")
end
- IO.write(file, "Type: `#{group[:type]}` \r\n")
IO.write(file, "#{group[:description]} \r\n\r\n")
for child <- group[:children] do
@@ -44,24 +44,36 @@ If you run Pleroma with ``MIX_ENV=prod`` the file is ``prod.secret.exs``, otherw
{:ok, config_path}
end
+ defp print_suggestion(file, suggestion) when is_list(suggestion) do
+ IO.write(file, " `#{inspect(suggestion)}`\r\n")
+ end
+
defp print_suggestion(file, suggestion) when is_function(suggestion) do
IO.write(file, " `#{inspect(suggestion.())}`\r\n")
end
- defp print_suggestion(file, suggestion) do
- IO.write(file, " `#{inspect(suggestion)}`\r\n")
+ defp print_suggestion(file, suggestion, as_list \\ false) do
+ list_mark = if as_list, do: "*", else: ""
+ IO.write(file, " #{list_mark} `#{inspect(suggestion)}`\r\n")
end
+ defp print_suggestions(_file, nil), do: nil
+
defp print_suggestions(file, suggestions) do
- IO.write(file, "Suggestions: \r\n")
+ IO.write(file, " Suggestions: \r\n")
- for suggestion <- suggestions do
- print_suggestion(file, suggestion)
+ if length(suggestions) > 1 do
+ for suggestion <- suggestions do
+ print_suggestion(file, suggestion, true)
+ end
+ else
+ print_suggestion(file, List.first(suggestions))
end
end
defp print_child_header(file, child) do
- IO.write(file, "* `#{inspect(child[:key])}`: #{child[:description]} \r\n")
- IO.write(file, "Type: `#{inspect(child[:type])}` \r\n")
+ IO.write(file, "* `#{inspect(child[:key])}` \r\n")
+ IO.write(file, " #{child[:description]} \r\n")
+ IO.write(file, " Type: `#{inspect(child[:type])}` \r\n")
end
end