File 0263-stdlib-Prepend-application-to-shell_docs-render-all-.patch of Package erlang
From c63842df90c71b55b0161ad8293389c9011e428f Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 20 Jan 2021 16:06:22 +0100
Subject: [PATCH 3/7] stdlib: Prepend application to shell_docs render all test
This is done in order to make it easier to compare docs from
the same application.
---
lib/stdlib/test/shell_docs_SUITE.erl | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/lib/stdlib/test/shell_docs_SUITE.erl b/lib/stdlib/test/shell_docs_SUITE.erl
index 1f8d70189f..26ebb5d4e8 100644
--- a/lib/stdlib/test/shell_docs_SUITE.erl
+++ b/lib/stdlib/test/shell_docs_SUITE.erl
@@ -184,9 +184,25 @@ b2a(Bin) ->
%% Testing functions
render_all(Dir) ->
file:make_dir(Dir),
+ %% We load all possible application in order to be able to use
+ %% application:get_application to get the application a module
+ %% belongs to.
+ PossibleApplications =
+ lists:flatmap(
+ fun(P) ->
+ filelib:wildcard(filename:join(P, "*.app"))
+ end, code:get_path()),
+ [application:load(list_to_atom(filename:basename(filename:rootname(App)))) ||
+ App <- PossibleApplications],
docsmap(
fun(Mod, #docs_v1{ docs = Docs } = D) ->
- SMod = atom_to_list(Mod),
+ case application:get_application(Mod) of
+ {ok, App} ->
+ App;
+ _ ->
+ App = unknown
+ end,
+ SMod = atom_to_list(App) ++ "_" ++ atom_to_list(Mod),
file:write_file(filename:join(Dir,SMod ++ ".txt"),
unicode:characters_to_binary(shell_docs:render(Mod, D))),
file:write_file(filename:join(Dir,SMod ++ "_type.txt"),
@@ -194,12 +210,14 @@ render_all(Dir) ->
file:write_file(filename:join(Dir,SMod ++ "_cb.txt"),
unicode:characters_to_binary(shell_docs:render_callback(Mod, D))),
lists:foreach(
- fun({{function,Name,Arity},_Anno,_Sig,_Doc,_Meta}) ->
+ fun({_Type,_Anno,_Sig,none,_Meta}) ->
+ ok;
+ ({{function,Name,Arity},_Anno,_Sig,_Doc,_Meta}) ->
FName = SMod ++ "_"++atom_to_list(Name)++"_"++integer_to_list(Arity)++"_func.txt",
ok = file:write_file(filename:join(Dir,re:replace(FName,"[/:]","_",
[global,{return,list}])),
unicode:characters_to_binary(shell_docs:render(Mod, Name, Arity, D)));
- ({{type,Name,Arity},_Anno,_Sig,_Doc,_Meta}) ->
+ ({{type,Name,Arity},_Anno,_Sig,_Doc,_Meta}) ->
FName = SMod ++ "_"++atom_to_list(Name)++"_"++integer_to_list(Arity)++"_type.txt",
ok = file:write_file(filename:join(Dir,re:replace(FName,"[/:]","_",
[global,{return,list}])),
--
2.26.2