diff options
-rw-r--r-- | doc/Makefile | 7 | ||||
-rw-r--r-- | doc/commercial.tex | 13 | ||||
-rwxr-xr-x | doc/mod_admin_p1_commands.sh | 99 |
3 files changed, 117 insertions, 2 deletions
diff --git a/doc/Makefile b/doc/Makefile index 896163a04..5c0916695 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -21,6 +21,7 @@ release: @echo "\newcommand{\version}{"`sed '/vsn/!d;s/\(.*\)"\(.*\)"\(.*\)/\2/' ../src/ejabberd.app`"}" >> version.tex @echo -n "% Contributed modules (automatically generated)." > contributed_modules.tex @echo -e "$(CONTRIBUTED_MODULES)" >> contributed_modules.tex + @echo "% mod_admin_p1 commands list." html: guide.html dev.html features.html commercial.html @@ -61,10 +62,12 @@ guide.pdf: guide.tex features.pdf: features.tex pdflatex features.tex -guide.html: commercial.tex +commercial.html: commercial.tex + ./mod_admin_p1_commands.sh hevea -fix -pedantic commercial.tex -guide.pdf: commercial.tex +commercial.pdf: commercial.tex + ./mod_admin_p1_commands.sh pdflatex commercial.tex pdflatex commercial.tex pdflatex commercial.tex diff --git a/doc/commercial.tex b/doc/commercial.tex index 6af918cd7..1c1d1d162 100644 --- a/doc/commercial.tex +++ b/doc/commercial.tex @@ -66,6 +66,7 @@ \newcommand{\module}[1]{\texttt{#1}} \newcommand{\modack}{\module{mod\_ack}} \newcommand{\modadhoc}{\module{mod\_adhoc}} +\newcommand{\modadminp}{\module{mod\_admin\_p1}} \newcommand{\modannounce}{\module{mod\_announce}} \newcommand{\modannounceodbc}{\module{mod\_announce\_odbc}} \newcommand{\modapplepush}{\module{mod\_applepush}} @@ -136,6 +137,7 @@ the processing discipline for #1 IQ queries (see section~\ref{modiqdiscoption}). %% Title page \include{version} +\include{mod_admin} \newlength{\larg} \setlength{\larg}{14.5cm} \title{ @@ -2604,6 +2606,7 @@ The following table lists all modules included in \ejabberd{}. \hline \hline \ahrefloc{modack}{\modack{}} & Reliable message delivery & \\ \hline \modadhoc{} & Ad-Hoc Commands (\xepref{0050}) & \\ + \hline \modadminp{} & Extended administration commands & \\ \hline \ahrefloc{modannounce}{\modannounce{}} & Manage announcements & recommends \modadhoc{} \\ \hline \ahrefloc{modannounce}{\modannounceodbc{}} & Manage announcements & recommends \modadhoc{} \\ & & supported DB (*) \\ @@ -2809,6 +2812,16 @@ to check the connection status of the recipient after every sent message. Since the latter procedure is not very effective, clients are encouraged to support \xepref{0184}. +\makesubsection{modadminp}{\modadminp{}} +\ind{modules!\modadminp{}} + +This module provides additional administration commands. +Use \verb|ejabberdctl help| to get the detailed information about the commands. + +Currently available commands: + +\modadminsection{} + \makesubsection{modannounce}{\modannounce{}} \ind{modules!\modannounce{}}\ind{MOTD}\ind{message of the day}\ind{announcements} diff --git a/doc/mod_admin_p1_commands.sh b/doc/mod_admin_p1_commands.sh new file mode 100755 index 000000000..e8c5a9182 --- /dev/null +++ b/doc/mod_admin_p1_commands.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env escript +%% -*- erlang -*- + +-record(cmd, {name, desc, longdesc, args, result}). + +main(_) -> + Dir = filename:absname(filename:join(["..", "src"])), + FileIn = filename:join([Dir, "mod_admin_p1.erl"]), + {ok, Forms1} = epp_dodger:parse_file(FileIn, [no_fail]), + Comments = erl_comment_scan:file(FileIn), + Forms = erl_recomment:recomment_forms(Forms1, Comments), + Tree = erl_syntax:flatten_form_list(Forms), + AuxFile = "mod_admin.tex", + case file:open(AuxFile, [write]) of + {ok, Fd} -> + io:format(Fd, "\\newcommand{\\modadminsection}{\\begin{description}~n", []), + process(Fd, Tree), + io:format(Fd, "\\end{description}}~n", []), + file:close(Fd), + halt(0); + {error, Why} -> + io:format("failed to open file ~s: ~s", + [AuxFile, file:format_error(Why)]), + halt(1) + end. + +process(Fd, Tree) -> + case erl_syntax:type(Tree) of + record_expr -> + case erl_syntax_lib:analyze_record_expr(Tree) of + {record_expr, {ejabberd_commands, _}} -> + Fs = erl_syntax:record_expr_fields(Tree), + Cmd = lists:foldl( + fun(F, C) -> + Name = erl_syntax:record_field_name(F), + Value = erl_syntax:record_field_value(F), + case {erl_syntax:concrete(Name), + catch erl_syntax:concrete(Value)} of + {_, {'EXIT', _}} -> + C; + {name, V} -> + C#cmd{name = V}; + {desc, V} -> + C#cmd{desc = V}; + {longdesc, V} -> + C#cmd{longdesc = V}; + {args, V} -> + C#cmd{args = V}; + {result, V} -> + C#cmd{result = V}; + _ -> + C + end + end, #cmd{}, Fs), + format_command(Fd, Cmd); + _ -> + ok + end; + _ -> + case erl_syntax:subtrees(Tree) of + [] -> + ok; + List -> + lists:foreach( + fun(Group) -> + lists:foreach( + fun(Subtree) -> + process(Fd, Subtree) + end, Group) + end, List) + end + end. + +-define(B(S), S). + +format_command(Fd, #cmd{name = Cmd, + desc = Desc, + longdesc = _LongDesc, + args = ArgsDef, + result = _ResultDef}) -> + io:format(Fd, "\\titem{~s ~s} ~s~n", + [escape_underscores(atom_to_list(Cmd)), + flatten_arguments(ArgsDef), + escape_underscores(Desc)]). + +flatten_arguments(Args) -> + string:join( + lists:map( + fun({Name, _Type}) -> + escape_underscores(io_lib:format("~s", [Name])) + end, Args), + " "). + +escape_underscores(S) -> + lists:flatten( + [case C of + $_ -> "\\_"; + _ -> C + end || C <- S]). |