Skip to content

Commit

Permalink
kernel: Fix code:get_doc/1,2 when cover_compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
williamthome committed Feb 13, 2025
1 parent 53e6751 commit e167d95
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/kernel/src/code.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,11 @@ get_doc(Mod, #{sources:=[Source|Sources]}=Options) ->
ErtsDir ->
GetDoc(filename:join([ErtsDir, "ebin", atom_to_list(Mod) ++ ".beam"]))
end;
cover_compiled ->
case cover_compiled_filename(Mod) of
{ok, Filename} -> GetDoc(Filename);
{error, missing} -> {error, missing}
end;
Error when is_atom(Error) ->
{error, Error};
Fn ->
Expand Down Expand Up @@ -1955,6 +1960,20 @@ get_function_docs_from_ast({function,Anno,Name,Arity,_Code}, AST) ->
get_function_docs_from_ast(_, _) ->
[].

cover_compiled_filename(Mod) ->
cover_compiled_filename(get_path(), atom_to_list(Mod) ++ ".beam").

cover_compiled_filename([], _Beam) ->
{error, missing};
cover_compiled_filename([Path | T], Beam) ->
Filename = filename:join(Path, Beam),
case filelib:is_regular(Filename) of
true ->
{ok, Filename};
false ->
cover_compiled_filename(T, Beam)
end.

%% Search the entire path system looking for name clashes

-doc """
Expand Down

0 comments on commit e167d95

Please sign in to comment.