aboutsummaryrefslogtreecommitdiffstats
path: root/lib/edoc/src/edoc.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2019-02-27 14:50:55 +0100
committerHans Bolinder <[email protected]>2019-02-27 14:50:55 +0100
commit0c3014ec38ef6adbe9369afe7c440b547fa321a1 (patch)
tree6743a84e37873d30b2f07c7bd0afbf323a4408d2 /lib/edoc/src/edoc.erl
parent8967a65b28fd9e7b705c619aac16328125f2d1bf (diff)
parentaa1135ccc2354841c00b40da5f7260dc299b7bf3 (diff)
downloadotp-0c3014ec38ef6adbe9369afe7c440b547fa321a1.tar.gz
otp-0c3014ec38ef6adbe9369afe7c440b547fa321a1.tar.bz2
otp-0c3014ec38ef6adbe9369afe7c440b547fa321a1.zip
Merge branch 'maint'
* maint: edoc: Print a helpful message if reading source file fails
Diffstat (limited to 'lib/edoc/src/edoc.erl')
-rw-r--r--lib/edoc/src/edoc.erl17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/edoc/src/edoc.erl b/lib/edoc/src/edoc.erl
index b641118c5d..e9d62d3283 100644
--- a/lib/edoc/src/edoc.erl
+++ b/lib/edoc/src/edoc.erl
@@ -578,7 +578,7 @@ read_source(Name, Opts0) ->
Opts = expand_opts(Opts0),
case read_source_1(Name, Opts) of
{ok, Forms} ->
- check_forms(Forms, Name),
+ check_forms(Forms, Name, Opts),
Forms;
{error, R} ->
edoc_report:error({"error reading file '~ts'.",
@@ -692,13 +692,19 @@ fll([T | L], LastLine, Ts) ->
fll(L, _LastLine, Ts) ->
lists:reverse(L, Ts).
-check_forms(Fs, Name) ->
+check_forms(Fs, Name, Opts) ->
Fun = fun (F) ->
case erl_syntax:type(F) of
error_marker ->
case erl_syntax:error_marker_info(F) of
{L, M, D} ->
- edoc_report:error(L, Name, {format_error, M, D});
+ edoc_report:error(L, Name, {format_error, M, D}),
+ case proplists:get_bool(preprocess, Opts) of
+ true ->
+ ok;
+ false ->
+ helpful_message(Name)
+ end;
Other ->
edoc_report:report(Name, "unknown error in "
"source code: ~w.", [Other])
@@ -710,6 +716,11 @@ check_forms(Fs, Name) ->
end,
lists:foreach(Fun, Fs).
+helpful_message(Name) ->
+ Ms = ["If the error is caused by too exotic macro",
+ "definitions or uses of macros, adding option",
+ "{preprocess, true} can help. See also edoc(3)."],
+ lists:foreach(fun(M) -> edoc_report:report(Name, M, []) end, Ms).
%% @spec get_doc(File::filename()) -> {ModuleName, edoc_module()}
%% @equiv get_doc(File, [])