mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-14 22:00:16 +02:00
Show tags and definer module in generated API document when it's a gen_mod
This commit is contained in:
parent
41808a63a0
commit
b22779f018
|
@ -360,8 +360,8 @@ gen_param(Name, Type, Desc, HTMLOutput) ->
|
||||||
[?TAG(dt, [?TAG_R(strong, atom_to_list(Name)), <<" :: ">>, ?RAW(format_type(Type))]),
|
[?TAG(dt, [?TAG_R(strong, atom_to_list(Name)), <<" :: ">>, ?RAW(format_type(Type))]),
|
||||||
?TAG(dd, ?RAW(Desc))].
|
?TAG(dd, ?RAW(Desc))].
|
||||||
|
|
||||||
gen_doc(#ejabberd_commands{name=Name, tags=_Tags, desc=Desc, longdesc=LongDesc,
|
gen_doc(#ejabberd_commands{name=Name, tags=Tags, desc=Desc, longdesc=LongDesc,
|
||||||
args=Args, args_desc=ArgsDesc, note=Note,
|
args=Args, args_desc=ArgsDesc, note=Note, definer=Definer,
|
||||||
result=Result, result_desc=ResultDesc}=Cmd, HTMLOutput, Langs) ->
|
result=Result, result_desc=ResultDesc}=Cmd, HTMLOutput, Langs) ->
|
||||||
try
|
try
|
||||||
ArgsText = case ArgsDesc of
|
ArgsText = case ArgsDesc of
|
||||||
|
@ -389,6 +389,17 @@ gen_doc(#ejabberd_commands{name=Name, tags=_Tags, desc=Desc, longdesc=LongDesc,
|
||||||
[?TAG(dl, [gen_param(RName, Type, ResultDesc, HTMLOutput)])]
|
[?TAG(dl, [gen_param(RName, Type, ResultDesc, HTMLOutput)])]
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
TagsText = [?RAW(atom_to_list(Tag) ++ " ") || Tag <- Tags],
|
||||||
|
IsDefinerMod = case Definer of
|
||||||
|
unknown -> true;
|
||||||
|
_ -> lists:member(gen_mod, proplists:get_value(behaviour, Definer:module_info(attributes)))
|
||||||
|
end,
|
||||||
|
ModuleText = case IsDefinerMod of
|
||||||
|
true ->
|
||||||
|
[?TAG(h2, <<"Module:">>), ?TAG(p, ?RAW(atom_to_list(Definer)))];
|
||||||
|
false ->
|
||||||
|
[]
|
||||||
|
end,
|
||||||
NoteEl = case Note of
|
NoteEl = case Note of
|
||||||
"" -> [];
|
"" -> [];
|
||||||
_ -> ?TAG('div', "note-down", ?RAW(Note))
|
_ -> ?TAG('div', "note-down", ?RAW(Note))
|
||||||
|
@ -403,6 +414,8 @@ gen_doc(#ejabberd_commands{name=Name, tags=_Tags, desc=Desc, longdesc=LongDesc,
|
||||||
end,
|
end,
|
||||||
?TAG(h2, <<"Arguments:">>), ArgsText,
|
?TAG(h2, <<"Arguments:">>), ArgsText,
|
||||||
?TAG(h2, <<"Result:">>), ResultText,
|
?TAG(h2, <<"Result:">>), ResultText,
|
||||||
|
?TAG(h2, <<"Tags:">>), ?TAG(p, TagsText)]
|
||||||
|
++ ModuleText ++ [
|
||||||
?TAG(h2, <<"Examples:">>), gen_calls(Cmd, HTMLOutput, Langs)]
|
?TAG(h2, <<"Examples:">>), gen_calls(Cmd, HTMLOutput, Langs)]
|
||||||
catch
|
catch
|
||||||
_:Ex ->
|
_:Ex ->
|
||||||
|
@ -421,12 +434,13 @@ find_commands_definitions() ->
|
||||||
lists:flatmap(fun(P) ->
|
lists:flatmap(fun(P) ->
|
||||||
Mod = list_to_atom(filename:rootname(P)),
|
Mod = list_to_atom(filename:rootname(P)),
|
||||||
code:ensure_loaded(Mod),
|
code:ensure_loaded(Mod),
|
||||||
case erlang:function_exported(Mod, get_commands_spec, 0) of
|
Cs = case erlang:function_exported(Mod, get_commands_spec, 0) of
|
||||||
true ->
|
true ->
|
||||||
apply(Mod, get_commands_spec, []);
|
apply(Mod, get_commands_spec, []);
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
end
|
end,
|
||||||
|
[C#ejabberd_commands{definer = Mod} || C <- Cs]
|
||||||
end, filelib:wildcard("*.beam", Path))
|
end, filelib:wildcard("*.beam", Path))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user