Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix phx.routes mix task when docs return multiple annotations #5606

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions lib/mix/tasks/phx.routes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ defmodule Mix.Tasks.Phx.Routes do
defp get_line_number(module, function_name) do
{_, _, _, _, _, _, functions_list} = Code.fetch_docs(module)

function_infos =
{_, location_or_annotations, _, _, _}=
josevalim marked this conversation as resolved.
Show resolved Hide resolved
functions_list
|> Enum.find(fn {{type, name, _}, _, _, _, _} ->
|> Enum.find({nil, [location: nil], nil, nil, nil}, fn {{type, name, _}, _, _, _, _} ->
josevalim marked this conversation as resolved.
Show resolved Hide resolved
type == :function and name == function_name
end)

case function_infos do
{_, line, _, _, _} -> line
nil -> nil
case Keyword.keyword?(location_or_annotations) do
false -> location_or_annotations
true -> location_or_annotations[:location]
josevalim marked this conversation as resolved.
Show resolved Hide resolved
end
end
end