Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/ex_doc/formatter/html/autolink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ defmodule ExDoc.Formatter.HTML.Autolink do
entry <- [doc.id | doc.defaults],
do: prefix <> module.id <> "." <> entry

lib_dirs = extra_lib_dirs ++ elixir_lib_dirs() ++ erlang_lib_dirs()

%{
aliases: aliases,
docs_refs: docs_refs ++ types_refs,
extension: extension,
lib_dirs: extra_lib_dirs ++ elixir_lib_dirs() ++ erlang_lib_dirs(),
lib_dirs: lib_dirs,
modules_refs: modules_refs
}
end
Expand Down Expand Up @@ -562,7 +564,7 @@ defmodule ExDoc.Formatter.HTML.Autolink do
nil

path ->
path = List.to_string(path)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was the culprit, when inspecting variables we had:

lib_dirs: [
  {"/Users/wojtek/src/elixir-lang/elixir/lib/elixir/ebin",
   "https://hexdocs.pm/elixir/"},
  {"/Users/wojtek/src/elixir-lang/elixir/lib/eex/ebin",
   "https://hexdocs.pm/eex/"},
  {"/Users/wojtek/src/elixir-lang/elixir/lib/iex/ebin",
   "https://hexdocs.pm/iex/"},
  {"/Users/wojtek/src/elixir-lang/elixir/lib/logger/ebin",
   "https://hexdocs.pm/logger/"},
  {"/Users/wojtek/src/elixir-lang/elixir/lib/mix/ebin",
   "https://hexdocs.pm/mix/"},
  {"/Users/wojtek/src/elixir-lang/elixir/lib/ex_unit/ebin",
   "https://hexdocs.pm/ex_unit/"},
  {"/usr/local/opt/asdf/installs/erlang/21.1/lib",
   "http://www.erlang.org/doc/man/"}
]
path: "/Users/wojtek/src/elixir-lang/elixir/bin/../lib/mix/ebin/Elixir.Mix.Tasks.Compile.App.beam"

which explains the discrepancy.

I couldn't easily write a test for it, verified by regenerating Elixir docs.

path = path |> List.to_string() |> Path.expand()

lib_dirs
|> Enum.filter(fn {lib_dir, _} -> String.starts_with?(path, lib_dir) end)
Expand Down Expand Up @@ -594,17 +596,17 @@ defmodule ExDoc.Formatter.HTML.Autolink do
path =
case :code.where_is_file('Elixir.Kernel.beam') do
:non_existing -> ""
path -> List.to_string(path)
path -> path |> List.to_string() |> Path.expand()
end

if File.exists?(path) do
path =
elixir_root_lib =
path
|> Path.dirname()
|> Path.dirname()
|> Path.dirname()

path <> "/" <> app <> "/ebin"
elixir_root_lib <> "/" <> app <> "/ebin"
else
# if beam file doesn't exists it's likely an escript
Path.dirname(path)
Expand Down