diff --git a/src/ejabberd_commands.erl b/src/ejabberd_commands.erl index 416e26edf..0114b1720 100644 --- a/src/ejabberd_commands.erl +++ b/src/ejabberd_commands.erl @@ -86,7 +86,8 @@ get_commands_spec() -> args_desc = ["Path to file where generated " "documentation should be stored", "Regexp matching names of commands or modules " - "that will be included inside generated document", + "that will be included inside generated document, " + "or `runtime` to get commands registered at runtime", "Comma separated list of languages (chosen from `java`, `perl`, `xmlrpc`, `json`) " "that will have example invocation include in markdown document"], result_desc = "0 if command failed, 1 when succeeded", diff --git a/src/ejabberd_commands_doc.erl b/src/ejabberd_commands_doc.erl index a903610d3..cb6f29229 100644 --- a/src/ejabberd_commands_doc.erl +++ b/src/ejabberd_commands_doc.erl @@ -477,8 +477,16 @@ maybe_add_policy_arguments(#ejabberd_commands{args=Args1, policy=user}=Cmd) -> maybe_add_policy_arguments(Cmd) -> Cmd. +generate_md_output(File, <<"runtime">>, Languages) -> + Cmds = lists:map(fun({N, _, _}) -> + ejabberd_commands:get_command_definition(N) + end, ejabberd_commands:list_commands()), + generate_md_output(File, <<".">>, Languages, Cmds); generate_md_output(File, RegExp, Languages) -> Cmds = find_commands_definitions(), + generate_md_output(File, RegExp, Languages, Cmds). + +generate_md_output(File, RegExp, Languages, Cmds) -> {ok, RE} = re:compile(RegExp), Cmds2 = lists:filter(fun(#ejabberd_commands{name=Name, module=Module}) -> re:run(atom_to_list(Name), RE, [{capture, none}]) == match orelse