From 86113f3494fc028dbba23f0519e73a5c1a98bc16 Mon Sep 17 00:00:00 2001 From: Zhongwen Deng Date: Mon, 30 May 2022 22:01:25 +0800 Subject: [PATCH] chore: don't gen example.conf in v5.0.0 --- apps/emqx_conf/src/emqx_conf.erl | 6 ++++-- apps/emqx_conf/src/hocon_schema_example.erl | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/emqx_conf/src/emqx_conf.erl b/apps/emqx_conf/src/emqx_conf.erl index e9a6abadb..aa28e81c3 100644 --- a/apps/emqx_conf/src/emqx_conf.erl +++ b/apps/emqx_conf/src/emqx_conf.erl @@ -27,6 +27,7 @@ -export([reset/2, reset/3]). -export([dump_schema/1, dump_schema/3]). -export([schema_module/0]). +-export([gen_example_conf/4]). %% for rpc -export([get_node_and_config/1]). @@ -144,8 +145,9 @@ dump_schema(Dir, SchemaModule, I18nFile) -> lists:foreach( fun(Lang) -> gen_config_md(Dir, I18nFile, SchemaModule, Lang), - gen_hot_conf_schema_json(Dir, I18nFile, Lang), - gen_example_conf(Dir, I18nFile, SchemaModule, Lang) + gen_hot_conf_schema_json(Dir, I18nFile, Lang) + %% TODO + %%gen_example_conf(Dir, I18nFile, SchemaModule, Lang) end, [en, zh] ), diff --git a/apps/emqx_conf/src/hocon_schema_example.erl b/apps/emqx_conf/src/hocon_schema_example.erl index 189be6787..050075e43 100644 --- a/apps/emqx_conf/src/hocon_schema_example.erl +++ b/apps/emqx_conf/src/hocon_schema_example.erl @@ -324,7 +324,10 @@ fmt_desc(_, _) -> fmt_type(Type, Indent) -> [Indent, ?COMMENT2, ?TYPE, Type, ?NL]. -fmt_path(Path, Indent) -> [Indent, ?COMMENT2, ?PATH, hocon_schema:path(Path), ?NL]. +fmt_path(Path, Indent) -> [Indent, ?COMMENT2, ?PATH, path(Path), ?NL]. + +path(Stack) when is_list(Stack) -> + string:join(lists:reverse(lists:map(fun str/1, Stack)), "."). fmt_fix_header(Field, Type, Path, #{indent := Indent}) -> [ @@ -350,7 +353,7 @@ fmt_map_link2(Path0, ValueName, All, Opts) -> {ok, #{paths := SubPaths}} -> SubPaths; _ -> [] end, - PathStr = hocon_schema:path(Path0), + PathStr = path(Path0), Path = bin(PathStr), #{indent := Indent} = Opts, case find_link(Opts, {map, PathStr}) of @@ -391,7 +394,7 @@ fmt_array_link(Type = #{elements := ElemT}, Path, Opts = #{indent := Indent}) -> end. link(Link, Indent) -> - [Indent, ?COMMENT2, ?LINK, hocon_schema:path(Link), ?NL]. + [Indent, ?COMMENT2, ?LINK, path(Link), ?NL]. is_simple_type(Types) when is_list(Types) -> lists:all( @@ -404,7 +407,7 @@ is_simple_type(Type) -> is_simple_type([Type]). need_comment_example(map, Opts, Path) -> - case find_link(Opts, {map, hocon_schema:path(Path)}) of + case find_link(Opts, {map, path(Path)}) of {ok, _} -> false; {error, not_found} -> true end.