fix for subgroup tuple
authorAlexander <alex.strizhakov@gmail.com>
Fri, 20 Dec 2019 07:22:53 +0000 (10:22 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Fri, 10 Jan 2020 12:52:01 +0000 (15:52 +0300)
added settings for swoosh adapters local

config/description.exs
lib/pleroma/docs/generator.ex
test/docs/generator_test.exs

index 3abcc62669370eceb42d3a519c0b5d12d7390776..52f7d2017b5b85d786858f3143111c8959558d0e 100644 (file)
@@ -238,7 +238,8 @@ config :pleroma, :config_description, [
           Swoosh.Adapters.AmazonSES,
           Swoosh.Adapters.Dyn,
           Swoosh.Adapters.SocketLabs,
-          Swoosh.Adapters.Gmail
+          Swoosh.Adapters.Gmail,
+          Swoosh.Adapters.Local
         ]
       },
       %{
@@ -449,6 +450,26 @@ config :pleroma, :config_description, [
       }
     ]
   },
+  %{
+    group: :swoosh,
+    type: :group,
+    description: "`Swoosh.Adapters.Local` adapter specific settings",
+    children: [
+      %{
+        group: {:subgroup, Swoosh.Adapters.Local},
+        key: :serve_mailbox,
+        type: :boolean,
+        description: "Run the preview server together as part of your app"
+      },
+      %{
+        group: {:subgroup, Swoosh.Adapters.Local},
+        key: :preview_port,
+        type: :integer,
+        description: "The preview server port",
+        suggestions: [4001]
+      }
+    ]
+  },
   %{
     group: :pleroma,
     key: :uri_schemes,
index b57e47e8be71148fcfdb84975c83f637194716be..6b12dcdd9901558d350f8e0abad086e87309510d 100644 (file)
@@ -58,15 +58,23 @@ defmodule Pleroma.Docs.Generator do
     entity
     |> Map.put(:suggestions, format_suggestions(suggestions))
     |> format_key()
+    |> format_group()
     |> format_children()
   end
 
   defp format_child(entity) do
     entity
     |> format_key()
+    |> format_group()
     |> format_children()
   end
 
+  defp format_group(%{group: group} = entity) do
+    Map.put(entity, :group, format_suggestion(group))
+  end
+
+  defp format_group(entity), do: entity
+
   defp atom_to_string(entity) when is_binary(entity), do: entity
 
   defp atom_to_string(entity) when is_atom(entity), do: inspect(entity)
index 42e7c32c8022a8e0fb9bfcab6ffaf6bcd6b58e15..0106809c2d9106c275401d35ce13bd4aba946288 100644 (file)
@@ -207,5 +207,12 @@ defmodule Pleroma.Docs.GeneratorTest do
       child = Enum.at(children, 7)
       assert child[:key] == "application/xml"
     end
+
+    test "subgroup with module name" do
+      [%{children: children} | _] = Generator.convert_to_strings(@descriptions)
+
+      %{group: subgroup} = Enum.at(children, 6)
+      assert subgroup == {":subgroup", "Swoosh.Adapters.SMTP"}
+    end
   end
 end