25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

New 'note' field in commands and options documentation

This commit is contained in:
Badlop 2021-05-05 11:41:06 +02:00
parent 78c09789f7
commit 999d0af502
3 changed files with 14 additions and 2 deletions

View File

@ -51,6 +51,7 @@
desc = "" :: string() | '_' | '$3',
longdesc = "" :: string() | '_',
version = 0 :: integer(),
note = "" :: string(),
weight = 1 :: integer(),
module :: atom() | '_',
function :: atom() | '_',

View File

@ -83,6 +83,8 @@ md_tag(h2, V) ->
[<<"\n__">>, V, <<"__\n\n">>];
md_tag(strong, V) ->
[<<"*">>, V, <<"*">>];
md_tag('div', V) ->
[<<"<div class='note-down'>">>, V, <<"</div>">>];
md_tag(_, V) ->
V.
@ -359,7 +361,7 @@ gen_param(Name, Type, Desc, HTMLOutput) ->
?TAG(dd, ?RAW(Desc))].
gen_doc(#ejabberd_commands{name=Name, tags=_Tags, desc=Desc, longdesc=LongDesc,
args=Args, args_desc=ArgsDesc,
args=Args, args_desc=ArgsDesc, note=Note,
result=Result, result_desc=ResultDesc}=Cmd, HTMLOutput, Langs) ->
try
ArgsText = case ArgsDesc of
@ -387,8 +389,13 @@ gen_doc(#ejabberd_commands{name=Name, tags=_Tags, desc=Desc, longdesc=LongDesc,
[?TAG(dl, [gen_param(RName, Type, ResultDesc, HTMLOutput)])]
end
end,
NoteEl = case Note of
"" -> [];
_ -> ?TAG('div', "note-down", ?RAW(Note))
end,
[?TAG(h1, atom_to_list(Name)),
[NoteEl,
?TAG(h1, atom_to_list(Name)),
?TAG(p, ?RAW(Desc)),
case LongDesc of
"" -> [];

View File

@ -159,6 +159,10 @@ opt_to_man(Lang, {Option, Options, Children}, Level) ->
lists:keysort(1, Children))]) ++
[io_lib:nl()|format_example(Level, Lang, Options)].
format_option(Lang, Option, #{note := Note, value := Val}) ->
"\n\n_Note_ about the next option: " ++ Note ++ ":\n\n"++
"*" ++ atom_to_list(Option) ++ "*: 'pass:[" ++
tr(Lang, Val) ++ "]'::";
format_option(Lang, Option, #{value := Val}) ->
"*" ++ atom_to_list(Option) ++ "*: 'pass:[" ++
tr(Lang, Val) ++ "]'::";