Skip to content

Commit

Permalink
Handle cover-compiled modules, closes #1395
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Sep 21, 2021
1 parent 8494c92 commit b7293ad
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lib/ex_doc/autolink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,24 @@ defmodule ExDoc.Autolink do
:preloaded ->
{true, :erts}

path when is_list(path) ->
otp? = :string.prefix(path, :code.lib_dir()) != :nomatch
maybe_path ->
otp? = is_list(maybe_path) and List.starts_with?(maybe_path, :code.lib_dir())

app =
case :application.get_application(module) do
{:ok, app} ->
app

_ ->
case path |> Path.split() |> Enum.reverse() do
[_, "ebin", app, "lib" | _] ->
String.to_atom(app)

_ ->
nil
with true <- is_list(maybe_path),
[_, "ebin", app, "lib" | _] <- maybe_path |> Path.split() |> Enum.reverse() do
String.to_atom(app)
else
_ -> nil
end
end

{otp?, app}

:non_existing ->
{false, nil}
end
end

Expand Down

0 comments on commit b7293ad

Please sign in to comment.