From aa3f8d6735cae1d9876627fd6e973ae0fb2a8f08 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Thu, 21 Dec 2023 17:13:37 +0100 Subject: [PATCH] fix(typedoc): meld it into the field doc in the meantime --- apps/emqx_conf/src/emqx_conf.erl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/emqx_conf/src/emqx_conf.erl b/apps/emqx_conf/src/emqx_conf.erl index 4f845a166..0a8339ddd 100644 --- a/apps/emqx_conf/src/emqx_conf.erl +++ b/apps/emqx_conf/src/emqx_conf.erl @@ -323,10 +323,12 @@ format_fields(Fields, DescResolver) -> [format_field(F, DescResolver) || F <- Fields]. format_field(#{name := Name, aliases := Aliases, type := Type} = F, DescResolver) -> + TypeDoc = format_type_desc(Type, DescResolver), L = [ {text, Name}, {type, format_type(Type)}, - {typedoc, format_type_desc(Type, DescResolver)}, + %% TODO: Make it into a separate field. + %% {typedoc, format_type_desc(Type, DescResolver)}, {refs, format_refs(Type)}, {aliases, case Aliases of @@ -334,7 +336,7 @@ format_field(#{name := Name, aliases := Aliases, type := Type} = F, DescResolver _ -> Aliases end}, {default, maps:get(hocon, maps:get(default, F, #{}), undefined)}, - {doc, maps:get(desc, F, undefined)} + {doc, join_format([maps:get(desc, F, undefined), TypeDoc])} ], maps:from_list([{K, V} || {K, V} <- L, V =/= undefined]). @@ -577,6 +579,14 @@ hocon_schema_to_spec(Atom, _LocalModule) when is_atom(Atom) -> typename_to_spec(TypeStr, Module) -> emqx_conf_schema_types:readable_dashboard(Module, TypeStr). +join_format(Snippets) -> + case [S || S <- Snippets, S =/= undefined] of + [] -> + undefined; + NonEmpty -> + to_bin(lists:join("
", NonEmpty)) + end. + to_bin(List) when is_list(List) -> iolist_to_binary(List); to_bin(Boolean) when is_boolean(Boolean) -> Boolean; to_bin(Atom) when is_atom(Atom) -> atom_to_binary(Atom, utf8);