summaryrefslogtreecommitdiff
path: root/lib/edoc
diff options
context:
space:
mode:
authorRadek Szymczyszyn <radoslaw.szymczyszyn@erlang-solutions.com>2020-12-07 18:19:59 +0100
committerRadek Szymczyszyn <radoslaw.szymczyszyn@erlang-solutions.com>2020-12-21 10:33:15 +0100
commit0ca724a21d6d37229c5cfc5961af69bc1c0297e2 (patch)
tree28a05597d868eeb1f4e67e6a8bb5e4d056d435fd /lib/edoc
parent63d0d7125db3aaa0a6260310f4c24cd0fb457457 (diff)
downloaderlang-0ca724a21d6d37229c5cfc5961af69bc1c0297e2.tar.gz
Remove ?NO_APP, use atom no_app
This fixes: edoc_lib.erl:804: Function get_doc_env/1 has no local return edoc_lib.erl:805: The call edoc_lib:get_doc_env ([], [], Opts :: any()) breaks the contract (App, Modules, Options) -> edoc:env() when App :: atom(), Modules :: [module()], Options :: proplist() edoc_run.erl:135: The created fun has no local return done in 0m7.25s The first empty list in the call to edoc_lib:get_doc_env/3 above is ?NO_APP. The atom `no_app` remains human-readable after the code is compiled, whereas the macro name gets erased.
Diffstat (limited to 'lib/edoc')
-rw-r--r--lib/edoc/include/edoc_doclet.hrl4
-rw-r--r--lib/edoc/src/edoc.erl4
-rw-r--r--lib/edoc/src/edoc_doclet.erl13
-rw-r--r--lib/edoc/src/edoc_lib.erl18
4 files changed, 15 insertions, 24 deletions
diff --git a/lib/edoc/include/edoc_doclet.hrl b/lib/edoc/include/edoc_doclet.hrl
index c15ba13aad..40ed77cff9 100644
--- a/lib/edoc/include/edoc_doclet.hrl
+++ b/lib/edoc/include/edoc_doclet.hrl
@@ -26,14 +26,12 @@
%% Author contact: carlsson.richard@gmail.com
%% =====================================================================
--define(NO_APP, []).
-
-record(doclet_context, {dir = "",
env,
opts = []}).
-record(doclet_gen, {sources = [],
- app = ?NO_APP,
+ app = no_app,
modules = []}).
-record(doclet_toc, {paths,
diff --git a/lib/edoc/src/edoc.erl b/lib/edoc/src/edoc.erl
index 24740942e2..152eb9a1d4 100644
--- a/lib/edoc/src/edoc.erl
+++ b/lib/edoc/src/edoc.erl
@@ -381,7 +381,7 @@ run(Files, Opts0) ->
Path = proplists:append_values(source_path, Opts),
Ss = sources(Path, Opts),
{Ss1, Ms} = expand_sources(expand_files(Files) ++ Ss, Opts),
- App = proplists:get_value(application, Opts, ?NO_APP),
+ App = proplists:get_value(application, Opts, no_app),
{App1, Ms1} = target_dir_info(Dir, App, Ms, Opts),
Ms2 = edoc_lib:unique(lists:sort(Ms1)),
Env = edoc_lib:get_doc_env(App1, Ms2, Opts),
@@ -453,7 +453,7 @@ target_dir_info(Dir, App, Ms, Opts) ->
{App, Ms};
false ->
{App1, Ms1} = edoc_lib:read_info_file(Dir),
- {if App == ?NO_APP -> App1;
+ {if App == no_app -> App1;
true -> App
end,
Ms ++ Ms1}
diff --git a/lib/edoc/src/edoc_doclet.erl b/lib/edoc/src/edoc_doclet.erl
index ffeead89a3..8d51b3ce95 100644
--- a/lib/edoc/src/edoc_doclet.erl
+++ b/lib/edoc/src/edoc_doclet.erl
@@ -58,8 +58,7 @@
-export_type([command/0,
context/0,
doclet_gen/0,
- doclet_toc/0,
- no_app/0]).
+ doclet_toc/0]).
-type command() :: doclet_gen()
| doclet_toc().
@@ -70,14 +69,8 @@
opts :: [term()]}.
%% Context for doclets.
--type no_app() :: ?NO_APP.
-%% A value used to mark absence of an Erlang application
-%% context. Use the macro `NO_APP' defined in
-%% <a href="edoc_doclet.hrl">`edoc_doclet.hrl'</a>
-%% to produce this value.
-
-type doclet_gen() :: #doclet_gen{sources :: [string()],
- app :: no_app() | atom(),
+ app :: no_app | atom(),
modules :: [module()]}.
%% Doclet command.
@@ -181,7 +174,7 @@ gen(Sources, App, Modules, Ctxt) ->
title(App, Options) ->
proplists:get_value(title, Options,
- if App == ?NO_APP ->
+ if App == no_app ->
"Overview";
true ->
io_lib:fwrite("Application: ~ts", [App])
diff --git a/lib/edoc/src/edoc_lib.erl b/lib/edoc/src/edoc_lib.erl
index 9c894b3e0e..a460eca59c 100644
--- a/lib/edoc/src/edoc_lib.erl
+++ b/lib/edoc/src/edoc_lib.erl
@@ -608,7 +608,7 @@ write_file(Text, Dir, Name, Options) ->
%% @private
write_info_file(App, Modules, Dir) ->
Ts = [{modules, Modules}],
- Ts1 = if App =:= ?NO_APP -> Ts;
+ Ts1 = if App =:= no_app -> Ts;
true -> [{application, App} | Ts]
end,
S0 = [io_lib:fwrite("~p.\n", [T]) || T <- Ts1],
@@ -636,7 +636,7 @@ read_file(File) ->
%% Info files
info_file_data(Ts) ->
- App = proplists:get_value(application, Ts, ?NO_APP),
+ App = proplists:get_value(application, Ts, no_app),
Ms = proplists:append_values(modules, Ts),
{App, Ms}.
@@ -653,10 +653,10 @@ read_info_file(Dir) ->
{error, R} ->
R1 = file:format_error(R),
warning("could not read '~ts': ~ts.", [File, R1]),
- {?NO_APP, []}
+ {no_app, []}
end;
false ->
- {?NO_APP, []}
+ {no_app, []}
end.
parse_info_file(Text, Name) ->
@@ -665,10 +665,10 @@ parse_info_file(Text, Name) ->
info_file_data(Vs);
{error, eof} ->
warning("unexpected end of file in '~ts'.", [Name]),
- {?NO_APP, []};
+ {no_app, []};
{error, {_Line,Module,R}} ->
warning("~ts: ~ts.", [Module:format_error(R), Name]),
- {?NO_APP, []}
+ {no_app, []}
end.
parse_terms(Text) ->
@@ -796,7 +796,7 @@ get_doc_links(App, Modules, Opts) ->
make_links(Ds1, D, D).
make_links([{Dir, {App, Ms}} | Ds], A, M) ->
- A1 = if App == ?NO_APP -> A;
+ A1 = if App == no_app -> A;
true -> add_new(App, Dir, A)
end,
F = fun (K, D) -> add_new(K, Dir, D) end,
@@ -826,7 +826,7 @@ add_new(K, V, D) ->
-spec get_doc_env(proplist()) -> edoc:env().
get_doc_env(Opts) ->
- get_doc_env([], [], Opts).
+ get_doc_env(no_app, [], Opts).
%% @doc Creates an environment data structure used by parts of EDoc for
%% generating references, etc. See {@link edoc:run/2} for a description
@@ -840,7 +840,7 @@ get_doc_env(Opts) ->
%% DEFER-OPTIONS: edoc:run/2
-spec get_doc_env(App, Modules, Options) -> edoc:env() when
- App :: atom(),
+ App :: atom() | no_app,
Modules :: [module()],
Options :: proplist().
get_doc_env(App, Modules, Opts) ->