Skip to content

Commit

Permalink
stdlib: Change missing doc file to be a warning
Browse files Browse the repository at this point in the history
When we cannot find the documentation file, we issue a warning
instead of error do that compilation can complete anyway. This
so that we don't have to have the docs available when compiling
a file.
  • Loading branch information
garazdawi committed Jun 5, 2024
1 parent 601a012 commit a6c522f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions lib/stdlib/src/epp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,12 @@ scan_filedoc_content({string, _A, DocFilename}, Dot,
epp_reply(From, {error,{DocLoc,epp,{Doc, file, DocFilename}}}),
wait_req_scan(St)
end;
{error, enoent} ->
epp_reply(From, {warning,{DocLoc,epp,{Doc, file, DocFilename}}}),
epp_reply(From, {ok,
[{'-',DocLoc}, {atom, DocLoc, Doc}]
++ [{string, DocLoc, ""}, {dot,DocLoc}]}),
wait_req_scan(St);
{error, _} ->
epp_reply(From, {error,{DocLoc,epp,{Doc, file, DocFilename}}}),
wait_req_scan(St)
Expand Down
10 changes: 5 additions & 5 deletions lib/stdlib/test/epp_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ moduledoc_include(Config) when is_list(Config) ->
{attribute, _, moduledoc, ModuleDoc} = lists:keyfind(moduledoc, 3, List),
?assertEqual({ok, unicode:characters_to_binary(ModuleDoc)}, file:read_file(DocName)),

%% negative test: checks that we produce an expected error
ModuleErrContent = binary:replace(ModuleFileContent, <<"README">>, <<"NotExistingFile">>),
ModuleErrName = CreateFile("module_attr", "moduledoc_err.erl", ModuleErrContent),
{ok, ListErr} = epp:parse_file(ModuleErrName, []),
{error,{_,epp,{moduledoc,file, "NotExistingFile.md"}}} = lists:keyfind(error, 1, ListErr),
%% negative test: checks that we produce an expected warning
ModuleWarnContent = binary:replace(ModuleFileContent, <<"README">>, <<"NotExistingFile">>),
ModuleWarnName = CreateFile("module_attr", "moduledoc_err.erl", ModuleWarnContent),
{ok, ListWarn} = epp:parse_file(ModuleWarnName, []),
{warning,{_,epp,{moduledoc,file, "NotExistingFile.md"}}} = lists:keyfind(warning, 1, ListWarn),

ok.

Expand Down

0 comments on commit a6c522f

Please sign in to comment.