refactor: stop generating static hot-conf and bridges schema files

This commit is contained in:
Zaiming (Stone) Shi 2023-04-25 13:42:42 +02:00
parent 28a68a0ec7
commit 55c488fa95
2 changed files with 2 additions and 32 deletions

View File

@ -150,7 +150,6 @@ dump_schema(Dir, SchemaModule) ->
lists:foreach(
fun(Lang) ->
ok = gen_config_md(Dir, SchemaModule, Lang),
ok = gen_api_schema_json(Dir, Lang),
ok = gen_schema_json(Dir, SchemaModule, Lang)
end,
["en", "zh"]
@ -177,28 +176,6 @@ gen_schema_json(Dir, SchemaModule, Lang) ->
IoData = emqx_utils_json:encode(JsonMap, [pretty, force_utf8]),
ok = file:write_file(SchemaJsonFile, IoData).
%% TODO: delete this function when we stop generating this JSON at build time.
gen_api_schema_json(Dir, Lang) ->
gen_api_schema_json_hotconf(Dir, Lang),
gen_api_schema_json_bridge(Dir, Lang).
%% TODO: delete this function when we stop generating this JSON at build time.
gen_api_schema_json_hotconf(Dir, Lang) ->
File = schema_filename(Dir, "hot-config-schema-", Lang),
IoData = hotconf_schema_json(),
ok = write_api_schema_json_file(File, IoData).
%% TODO: delete this function when we stop generating this JSON at build time.
gen_api_schema_json_bridge(Dir, Lang) ->
File = schema_filename(Dir, "bridge-api-", Lang),
IoData = bridge_schema_json(),
ok = write_api_schema_json_file(File, IoData).
%% TODO: delete this function when we stop generating this JSON at build time.
write_api_schema_json_file(File, IoData) ->
io:format(user, "===< Generating: ~s~n", [File]),
file:write_file(File, IoData).
%% TODO: move this function to emqx_dashboard when we stop generating this JSON at build time.
hotconf_schema_json() ->
SchemaInfo = #{title => <<"EMQX Hot Conf API Schema">>, version => <<"0.1.0">>},
@ -209,10 +186,6 @@ bridge_schema_json() ->
SchemaInfo = #{title => <<"EMQX Data Bridge API Schema">>, version => <<"0.1.0">>},
gen_api_schema_json_iodata(emqx_bridge_api, SchemaInfo).
schema_filename(Dir, Prefix, Lang) ->
Filename = Prefix ++ Lang ++ ".json",
filename:join([Dir, Filename]).
%% TODO: remove it and also remove hocon_md.erl and friends.
%% markdown generation from schema is a failure and we are moving to an interactive
%% viewer like swagger UI.

7
build
View File

@ -92,7 +92,7 @@ log() {
}
make_docs() {
local libs_dir1 libs_dir2 libs_dir3 docdir dashboard_www_static
local libs_dir1 libs_dir2 libs_dir3 docdir
libs_dir1="$("$FIND" "_build/$PROFILE/lib/" -maxdepth 2 -name ebin -type d)"
if [ -d "_build/default/lib/" ]; then
libs_dir2="$("$FIND" "_build/default/lib/" -maxdepth 2 -name ebin -type d)"
@ -113,14 +113,11 @@ make_docs() {
;;
esac
docdir="_build/docgen/$PROFILE"
dashboard_www_static='apps/emqx_dashboard/priv/www/static/'
mkdir -p "$docdir" "$dashboard_www_static"
mkdir -p "$docdir"
# shellcheck disable=SC2086
erl -noshell -pa $libs_dir1 $libs_dir2 $libs_dir3 -eval \
"ok = emqx_conf:dump_schema('$docdir', $SCHEMA_MODULE), \
halt(0)."
cp "$docdir"/bridge-api-*.json "$dashboard_www_static"
cp "$docdir"/hot-config-schema-*.json "$dashboard_www_static"
}
assert_no_compile_time_only_deps() {