mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Mark toplevel options, commands and modules that changed in latest version
This commit is contained in:
parent
c98302b3c0
commit
7cd5808766
@ -415,7 +415,7 @@ gen_doc(#ejabberd_commands{name=Name, tags=Tags, desc=Desc, longdesc=LongDesc,
|
|||||||
true -> {NoteEl, []}
|
true -> {NoteEl, []}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
[?TAG(h1, atom_to_list(Name)),
|
[?TAG(h1, make_command_name(Name, Note)),
|
||||||
NotePre,
|
NotePre,
|
||||||
?TAG(p, ?RAW(Desc)),
|
?TAG(p, ?RAW(Desc)),
|
||||||
case LongDesc of
|
case LongDesc of
|
||||||
@ -435,6 +435,19 @@ gen_doc(#ejabberd_commands{name=Name, tags=Tags, desc=Desc, longdesc=LongDesc,
|
|||||||
[Name, Ex])))
|
[Name, Ex])))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
get_version_mark("") ->
|
||||||
|
"";
|
||||||
|
get_version_mark(Note) ->
|
||||||
|
[XX, YY | _] = string:tokens(binary_to_list(ejabberd_option:version()), "."),
|
||||||
|
XXYY = string:join([XX, YY], "."),
|
||||||
|
case string:find(Note, XXYY) of
|
||||||
|
nomatch -> "";
|
||||||
|
_ -> " 🟤"
|
||||||
|
end.
|
||||||
|
|
||||||
|
make_command_name(Name, Note) ->
|
||||||
|
atom_to_list(Name) ++ get_version_mark(Note).
|
||||||
|
|
||||||
find_commands_definitions() ->
|
find_commands_definitions() ->
|
||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
fun(Mod) ->
|
fun(Mod) ->
|
||||||
@ -492,21 +505,22 @@ generate_md_output(File, RegExp, Languages, Cmds) ->
|
|||||||
end, Cmds2),
|
end, Cmds2),
|
||||||
Cmds4 = [maybe_add_policy_arguments(Cmd) || Cmd <- Cmds3],
|
Cmds4 = [maybe_add_policy_arguments(Cmd) || Cmd <- Cmds3],
|
||||||
Langs = binary:split(Languages, <<",">>, [global]),
|
Langs = binary:split(Languages, <<",">>, [global]),
|
||||||
Version = ejabberd_config:version(),
|
Version = binary_to_list(ejabberd_config:version()),
|
||||||
Header = <<"# API Reference\n\n"
|
Header = ["# API Reference\n\n"
|
||||||
"This section describes API of ejabberd ", Version/binary, ".\n\n">>,
|
"This section describes API commands of ejabberd ", Version, ". "
|
||||||
|
"The commands that changed in this version are marked with 🟤.\n\n"],
|
||||||
Out = lists:map(fun(C) -> gen_doc(C, false, Langs) end, Cmds4),
|
Out = lists:map(fun(C) -> gen_doc(C, false, Langs) end, Cmds4),
|
||||||
{ok, Fh} = file:open(File, [write]),
|
{ok, Fh} = file:open(File, [write, {encoding, utf8}]),
|
||||||
io:format(Fh, "~ts~ts", [Header, Out]),
|
io:format(Fh, "~ts~ts", [Header, Out]),
|
||||||
file:close(Fh),
|
file:close(Fh),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
generate_tags_md(File) ->
|
generate_tags_md(File) ->
|
||||||
Version = ejabberd_config:version(),
|
Version = binary_to_list(ejabberd_config:version()),
|
||||||
Header = <<"# API Tags\n\n"
|
Header = ["# API Tags\n\n"
|
||||||
"This section enumerates the API tags of ejabberd ", Version/binary, ".\n\n">>,
|
"This section enumerates the API tags of ejabberd ", Version, ". \n\n"],
|
||||||
Tags = make_tags(false),
|
Tags = make_tags(false),
|
||||||
{ok, Fh} = file:open(File, [write]),
|
{ok, Fh} = file:open(File, [write, {encoding, utf8}]),
|
||||||
io:format(Fh, "~ts~ts", [Header, Tags]),
|
io:format(Fh, "~ts~ts", [Header, Tags]),
|
||||||
file:close(Fh),
|
file:close(Fh),
|
||||||
ok.
|
ok.
|
||||||
|
@ -45,7 +45,8 @@ man(Lang) ->
|
|||||||
#{desc := Descr} = Map ->
|
#{desc := Descr} = Map ->
|
||||||
DocOpts = maps:get(opts, Map, []),
|
DocOpts = maps:get(opts, Map, []),
|
||||||
Example = maps:get(example, Map, []),
|
Example = maps:get(example, Map, []),
|
||||||
{[{M, Descr, DocOpts, #{example => Example}}|Mods], SubMods};
|
Note = maps:get(note, Map, []),
|
||||||
|
{[{M, Descr, DocOpts, #{example => Example, note => Note}}|Mods], SubMods};
|
||||||
#{opts := DocOpts} ->
|
#{opts := DocOpts} ->
|
||||||
{ParentMod, Backend} = strip_backend_suffix(M),
|
{ParentMod, Backend} = strip_backend_suffix(M),
|
||||||
{Mods, dict:append(ParentMod, {M, Backend, DocOpts}, SubMods)};
|
{Mods, dict:append(ParentMod, {M, Backend, DocOpts}, SubMods)};
|
||||||
@ -72,11 +73,12 @@ man(Lang) ->
|
|||||||
catch _:undef -> []
|
catch _:undef -> []
|
||||||
end
|
end
|
||||||
end, ejabberd_config:callback_modules(all)),
|
end, ejabberd_config:callback_modules(all)),
|
||||||
Version = ejabberd_config:version(),
|
Version = binary_to_list(ejabberd_config:version()),
|
||||||
Options =
|
Options =
|
||||||
["TOP LEVEL OPTIONS",
|
["TOP LEVEL OPTIONS",
|
||||||
"-----------------",
|
"-----------------",
|
||||||
tr(Lang, <<"This section describes top level options of ejabberd ", Version/binary, ".">>),
|
"This section describes top level options of ejabberd " ++ Version ++ ".",
|
||||||
|
"The options that changed in this version are marked with 🟤.",
|
||||||
io_lib:nl()] ++
|
io_lib:nl()] ++
|
||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
fun(Opt) ->
|
fun(Opt) ->
|
||||||
@ -96,13 +98,15 @@ man(Lang) ->
|
|||||||
"MODULES",
|
"MODULES",
|
||||||
"-------",
|
"-------",
|
||||||
"[[modules]]",
|
"[[modules]]",
|
||||||
tr(Lang, <<"This section describes modules options of ejabberd ", Version/binary, ".">>),
|
"This section describes modules options of ejabberd " ++ Version ++ ".",
|
||||||
|
"The modules that changed in this version are marked with 🟤.",
|
||||||
io_lib:nl()] ++
|
io_lib:nl()] ++
|
||||||
lists:flatmap(
|
lists:flatmap(
|
||||||
fun({M, Descr, DocOpts, Backends, Example}) ->
|
fun({M, Descr, DocOpts, Backends, Example}) ->
|
||||||
ModName = atom_to_list(M),
|
ModName = atom_to_list(M),
|
||||||
|
VersionMark = get_version_mark(Example),
|
||||||
[io_lib:nl(),
|
[io_lib:nl(),
|
||||||
ModName,
|
lists:flatten([ModName, VersionMark]),
|
||||||
lists:duplicate(length(atom_to_list(M)), $~),
|
lists:duplicate(length(atom_to_list(M)), $~),
|
||||||
"[[" ++ ModName ++ "]]",
|
"[[" ++ ModName ++ "]]",
|
||||||
io_lib:nl()] ++
|
io_lib:nl()] ++
|
||||||
@ -115,7 +119,7 @@ man(Lang) ->
|
|||||||
"LISTENERS",
|
"LISTENERS",
|
||||||
"-------",
|
"-------",
|
||||||
"[[listeners]]",
|
"[[listeners]]",
|
||||||
tr(Lang, <<"This section describes listeners options of ejabberd ", Version/binary, ".">>),
|
"This section describes listeners options of ejabberd " ++ Version ++ ".",
|
||||||
io_lib:nl(),
|
io_lib:nl(),
|
||||||
"TODO"],
|
"TODO"],
|
||||||
AsciiData =
|
AsciiData =
|
||||||
@ -163,13 +167,24 @@ opt_to_man(Lang, {Option, Options, Children}, Level) ->
|
|||||||
lists:keysort(1, Children))]) ++
|
lists:keysort(1, Children))]) ++
|
||||||
[io_lib:nl()|format_example(Level, Lang, Options)].
|
[io_lib:nl()|format_example(Level, Lang, Options)].
|
||||||
|
|
||||||
format_option(Lang, Option, #{value := Val}) ->
|
get_version_mark(#{note := Note}) ->
|
||||||
"*" ++ atom_to_list(Option) ++ "*: 'pass:[" ++
|
[XX, YY | _] = string:tokens(binary_to_list(ejabberd_option:version()), "."),
|
||||||
|
XXYY = string:join([XX, YY], "."),
|
||||||
|
case string:find(Note, XXYY) of
|
||||||
|
nomatch -> "";
|
||||||
|
_ -> " 🟤"
|
||||||
|
end;
|
||||||
|
get_version_mark(_) ->
|
||||||
|
"".
|
||||||
|
|
||||||
|
format_option(Lang, Option, #{value := Val} = Options) ->
|
||||||
|
VersionMark = get_version_mark(Options),
|
||||||
|
"*" ++ atom_to_list(Option) ++ VersionMark ++ "*: 'pass:[" ++
|
||||||
tr(Lang, Val) ++ "]'::";
|
tr(Lang, Val) ++ "]'::";
|
||||||
format_option(_Lang, Option, #{}) ->
|
format_option(_Lang, Option, #{}) ->
|
||||||
"*" ++ atom_to_list(Option) ++ "*::".
|
"*" ++ atom_to_list(Option) ++ "*::".
|
||||||
|
|
||||||
format_versions(Lang, #{note := Note}) ->
|
format_versions(_Lang, #{note := Note}) ->
|
||||||
["_Note_ about this option: " ++ Note ++ ". "];
|
["_Note_ about this option: " ++ Note ++ ". "];
|
||||||
format_versions(_, _) ->
|
format_versions(_, _) ->
|
||||||
[].
|
[].
|
||||||
|
Loading…
Reference in New Issue
Block a user