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: remove extra term() argument at start of macrocallback spec #1590

Merged
merged 3 commits into from Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/ex_doc/language/elixir.ex
Expand Up @@ -109,11 +109,14 @@ defmodule ExDoc.Language.Elixir do
if actual_def in module_data.private.optional_callbacks, do: ["optional"], else: []

specs =
case Map.fetch(module_data.private.callbacks, actual_def) do
{:ok, specs} ->
case module_data.private.callbacks do
%{^actual_def => specs} when kind == :macro_callback ->
josevalim marked this conversation as resolved.
Show resolved Hide resolved
Enum.map(specs, &remove_callback_term/1)

%{^actual_def => specs} ->
specs

:error ->
%{} ->
[]
end

Expand All @@ -136,6 +139,14 @@ defmodule ExDoc.Language.Elixir do
}
end

defp remove_callback_term({:type, num, :bounded_fun, [lhs, rhs]}) do
{:type, num, :bounded_fun, [remove_callback_term(lhs), rhs]}
end

defp remove_callback_term({:type, num, :fun, [{:type, num, :product, [_ | rest_args]} | rest]}) do
{:type, num, :fun, [{:type, num, :product, rest_args} | rest]}
end

@impl true
def type_data(entry, module_data) do
{{_kind, name, arity}, _anno, _signature, _doc, _metadata} = entry
Expand Down
2 changes: 1 addition & 1 deletion test/ex_doc/retriever/elixir_test.exs
Expand Up @@ -160,7 +160,7 @@ defmodule ExDoc.Retriever.ElixirTest do
assert macrocallback1.group == :Callbacks
assert Path.basename(macrocallback1.source_url) == "nofile:9"
refute macrocallback1.doc
assert Macro.to_string(macrocallback1.specs) == "[macrocallback1(term()) :: :ok]"
assert Macro.to_string(macrocallback1.specs) == "[macrocallback1() :: :ok]"

elixirc(c, ~S"""
defmodule Impl do
Expand Down