feat(schema): generate document when building the release

This commit is contained in:
Zaiming Shi 2021-09-08 10:29:25 +02:00
parent 687114eeb1
commit 01166a8bfb
3 changed files with 55 additions and 23 deletions

View File

@ -76,31 +76,41 @@
namespace() -> undefined. namespace() -> undefined.
roots() -> roots() ->
[{"zones", [ {"listeners",
sc(ref("listeners"),
#{ desc => "MQTT listeners identified by their protocol type and assigned names"
})
},
{"zones",
sc(map("name", ref("zone")), sc(map("name", ref("zone")),
#{ desc => "A zone is a set of configs grouped by the zone `$name`. <br>" #{ desc => "A zone is a set of configs grouped by the zone <code>name</code>. <br>"
"The `$name` can be set to a listner's `zone` config for " "For flexible configuration mapping, the <code>name</code> "
"flexible configuration mapping. <br>" "can be set to a listener's <code>zone</code> config . <br>"
"NOTE: A builtin zone named `default` is auto created " "NOTE: A builtin zone named <code>default</code> is auto created "
"and can not be deleted." "and can not be deleted."
})}, })},
"mqtt", {"mqtt",
"flapping_detect", sc(ref("mqtt"),
#{ desc => "Global MQTT configuration.<br>"
"The configs here work as default values which can be overriden "
"in <code>zone</code> configs"
})},
"rate_limit",
"force_shutdown", "force_shutdown",
"force_gc", "force_gc",
"conn_congestion", "conn_congestion",
"rate_limit",
"quota", "quota",
{"listeners",
sc(ref("listeners"),
#{ desc => "MQTT listeners identified by their protocol type and assigned names. "
"The listeners enabled by default are named with 'default'"})
},
"broker", "broker",
"plugins", "plugins", %% TODO: move to emqx_machine_schema
"stats", "stats",
"sysmon", "sysmon",
"alarm", "alarm",
{"authentication",
sc(hoconsc:lazy(hoconsc:array(map())),
#{ desc => "Default authentication configs for all MQTT listeners.<br>"
"For per-listener overrides see <code>authentication</code> "
"in listener configs"
})},
{"authentication", {"authentication",
sc(hoconsc:lazy(hoconsc:array(map())), sc(hoconsc:lazy(hoconsc:array(map())),
#{ desc => "Default authentication configs for all MQTT listeners.<br>" #{ desc => "Default authentication configs for all MQTT listeners.<br>"

View File

@ -59,13 +59,32 @@
namespace() -> undefined. namespace() -> undefined.
roots() -> roots() ->
%% This is a temp workaround to define part of authorization config lists:flatmap(fun roots/1, ?MERGED_CONFIGS) ++
%% in emqx_schema and part of it in emqx_authz_schema but then [ {"node",
%% merged here in this module sc(hoconsc:ref("node"),
%% The proper fix should be to make connection (channel, session) state #{ desc => "Node name, cookie, config & data directories "
%% extendable by e.g. allow hooks be stateful. "and the Eralng virtual machine (beam) boot parameters."
["cluster", "node", "rpc", "log", "authorization"] ++ })}
lists:keydelete("authorization", 1, lists:flatmap(fun roots/1, ?MERGED_CONFIGS)). , {"cluster",
sc(hoconsc:ref("cluster"),
#{ desc => "EMQ X nodes can form a cluster to scale up the total capacity.<br>"
"Here holds the configs to instruct how individual nodes "
"can discover each other, also the database replication "
"role of this node etc."
})}
, {"log",
sc(hoconsc:ref("log"),
#{ desc => "Configure logging backends (to console or to file), "
"and logging level for each logger backend."
})}
, {"rpc",
sc(hoconsc:ref("rpc"),
#{ desc => "EMQ X uses a library called <code>gen_rpc</code> for "
"inter-broker RPCs.<br>Most of the time the default config "
"should work, but in case you need to do performance "
"fine-turning or experiment a bit, this is where to look."
})}
].
fields("cluster") -> fields("cluster") ->
[ {"name", [ {"name",
@ -738,5 +757,4 @@ to_atom(Bin) when is_binary(Bin) ->
binary_to_atom(Bin, utf8). binary_to_atom(Bin, utf8).
roots(Module) -> roots(Module) ->
lists:map(fun({_BinName, Root}) -> Root end, lists:map(fun({_BinName, Root}) -> Root end, hocon_schema:roots(Module)).
maps:to_list(hocon_schema:roots(Module))).

4
build
View File

@ -69,6 +69,10 @@ make_rel() {
echo "gpb should not be included in the release" echo "gpb should not be included in the release"
exit 1 exit 1
fi fi
local conf_doc
conf_doc="$(pwd)/_build/${PROFILE}/rel/emqx/etc/emqx-config-doc.html"
echo "===< Generating config document $conf_doc"
./_build/"$PROFILE"/rel/emqx/bin/emqx cold_eval "file:write_file('$conf_doc', hocon_schema_html:gen(emqx_machine_schema, \"EMQ X ${PKG_VSN}\"))"
} }
## unzip previous version .zip files to _build/$PROFILE/rel/emqx/releases before making relup ## unzip previous version .zip files to _build/$PROFILE/rel/emqx/releases before making relup