Skip to content

Commit 6a58127

Browse files
author
José Valim
committed
Do not autogenerate docs for defdelegate
This would cause code with multiple clauses where the last one is a delegate to contain the wrong documentation.
1 parent bcbe91a commit 6a58127

File tree

2 files changed

+0
-32
lines changed

2 files changed

+0
-32
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4795,10 +4795,6 @@ defmodule Kernel do
47954795
for fun <- List.wrap(funs) do
47964796
{name, args, as, as_args} = Kernel.Utils.defdelegate(fun, opts)
47974797

4798-
unless Module.get_attribute(__MODULE__, :doc) do
4799-
@doc "See `#{inspect(target)}.#{as}/#{:erlang.length(args)}`."
4800-
end
4801-
48024798
def unquote(name)(unquote_splicing(args)) do
48034799
unquote(target).unquote(as)(unquote_splicing(as_args))
48044800
end

lib/iex/test/iex/helpers_test.exs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -495,34 +495,6 @@ defmodule IEx.HelpersTest do
495495
cleanup_modules([Impl, MyBehaviour])
496496
end
497497

498-
test "prints documentation for delegates" do
499-
filename = "delegate.ex"
500-
501-
content = """
502-
defmodule Delegator do
503-
defdelegate func1, to: Delegated
504-
@doc "Delegator func2 doc"
505-
defdelegate func2, to: Delegated
506-
end
507-
defmodule Delegated do
508-
def func1, do: 1
509-
def func2, do: 2
510-
end
511-
"""
512-
513-
with_file(filename, content, fn ->
514-
assert c(filename, ".") |> Enum.sort() == [Delegated, Delegator]
515-
516-
assert capture_io(fn -> h(Delegator.func1()) end) ==
517-
"* def func1()\n\nSee `Delegated.func1/0`.\n"
518-
519-
assert capture_io(fn -> h(Delegator.func2()) end) ==
520-
"* def func2()\n\nDelegator func2 doc\n"
521-
end)
522-
after
523-
cleanup_modules([Delegated, Delegator])
524-
end
525-
526498
test "prints modules compiled without docs" do
527499
Code.compiler_options(docs: false)
528500

0 commit comments

Comments
 (0)