Skip to content

Commit 25e480f

Browse files
committed
Do not break signatures over multiple lines
1 parent 2dc6773 commit 25e480f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/elixir/src/elixir_erl.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,9 @@ signature_to_binary(Module, '__struct__', []) ->
552552
<<"%", ('Elixir.Kernel':inspect(Module))/binary, "{}">>;
553553

554554
signature_to_binary(_, Name, Signature) ->
555-
'Elixir.Macro':to_string({Name, [{closing, []}], Signature}).
555+
Quoted = {Name, [{closing, []}], Signature},
556+
Doc = 'Elixir.Inspect.Algebra':format('Elixir.Code':quoted_to_algebra(Quoted), infinity),
557+
'Elixir.IO':iodata_to_binary(Doc).
556558

557559
checker_chunk(#{definitions := Definitions, deprecated := Deprecated, is_behaviour := IsBehaviour}) ->
558560
DeprecatedMap = maps:from_list(Deprecated),

lib/elixir/test/elixir/kernel/docs_test.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ defmodule Kernel.DocsTest do
119119

120120
def two_good_names(first, :ok), do: first
121121
def two_good_names(second, :error), do: second
122+
123+
def really_long_signature(
124+
really_long_var_named_one,
125+
really_long_var_named_two,
126+
really_long_var_named_three
127+
) do
128+
{really_long_var_named_one, really_long_var_named_two, really_long_var_named_three}
129+
end
122130
end
123131
)
124132

@@ -128,6 +136,7 @@ defmodule Kernel.DocsTest do
128136
assert [
129137
arg_names,
130138
only_underscore,
139+
really_long_signature,
131140
two_good_names,
132141
with_defaults,
133142
with_map_and_default,
@@ -141,6 +150,12 @@ defmodule Kernel.DocsTest do
141150
# only_underscore/1
142151
assert {{:only_underscore, 1}, ["only_underscore(_)"]} = only_underscore
143152

153+
# really_long_signature/3
154+
assert {{:really_long_signature, 3},
155+
[
156+
"really_long_signature(really_long_var_named_one, really_long_var_named_two, really_long_var_named_three)"
157+
]} = really_long_signature
158+
144159
# two_good_names/2
145160
assert {{:two_good_names, 2}, ["two_good_names(first, atom)"]} = two_good_names
146161

0 commit comments

Comments
 (0)