summaryrefslogtreecommitdiff
path: root/lib/edoc
diff options
context:
space:
mode:
authorRadek Szymczyszyn <radoslaw.szymczyszyn@erlang-solutions.com>2021-02-05 21:27:35 +0100
committerRadek Szymczyszyn <radoslaw.szymczyszyn@erlang-solutions.com>2021-02-05 21:27:35 +0100
commit52dc947014b4510a42bfd6cc13c9339fe3c7b58c (patch)
treeac4a4329e796bb78119e877a268451b842008fb9 /lib/edoc
parent3728facb9198a0ab166d539629395f6f8f7d26b5 (diff)
downloaderlang-52dc947014b4510a42bfd6cc13c9339fe3c7b58c.tar.gz
Adjust function signature formatting to better comply with EEP-48
Diffstat (limited to 'lib/edoc')
-rw-r--r--lib/edoc/src/edoc_layout_chunks.erl15
-rw-r--r--lib/edoc/test/eep48_SUITE.erl16
2 files changed, 17 insertions, 14 deletions
diff --git a/lib/edoc/src/edoc_layout_chunks.erl b/lib/edoc/src/edoc_layout_chunks.erl
index b94d429145..637b17b6b4 100644
--- a/lib/edoc/src/edoc_layout_chunks.erl
+++ b/lib/edoc/src/edoc_layout_chunks.erl
@@ -287,15 +287,18 @@ args_and_signature(E = #entry{}) ->
{Args, format_signature(Name, Args)}
end.
-format_signature(Name, Args) ->
- [list_to_binary(atom_to_list(Name)), <<"(">> | format_signature(Args)] ++ [<<"\n">>].
+format_signature(Name, []) ->
+ [<<(atom_to_binary(Name, utf8))/bytes, "()">>];
+format_signature(Name, [Arg]) ->
+ [<<(atom_to_binary(Name, utf8))/bytes, "(", (atom_to_binary(Arg, utf8))/bytes, ")">>];
+format_signature(Name, [Arg | Args]) ->
+ [<<(atom_to_binary(Name, utf8))/bytes, "(", (atom_to_binary(Arg, utf8))/bytes, ",">>
+ | format_signature(Args)].
-format_signature([]) ->
- [<<")">>];
format_signature([Arg]) ->
- [atom_to_binary(Arg, utf8), <<")">>];
+ [<<(atom_to_binary(Arg, utf8))/bytes, ")">>];
format_signature([Arg | Args]) ->
- [<<(atom_to_binary(Arg, utf8))/bytes, ", ">> | format_signature(Args)].
+ [<<(atom_to_binary(Arg, utf8))/bytes, ",">> | format_signature(Args)].
annotate_spec(ArgClauses, Spec, SourceFile, Line) ->
try
diff --git a/lib/edoc/test/eep48_SUITE.erl b/lib/edoc/test/eep48_SUITE.erl
index 3da71cc4c8..434faaf541 100644
--- a/lib/edoc/test/eep48_SUITE.erl
+++ b/lib/edoc/test/eep48_SUITE.erl
@@ -234,49 +234,49 @@ equiv(Config) ->
f_sig_single_simple_clause(Config) ->
Docs = get_docs(Config, eep48_sigs),
%?debugVal(Docs, 1000),
- ?assertEqual([?a2b(?FUNCTION_NAME),<<"(">>,<<"Arg">>,<<")">>,<<"\n">>],
+ ?assertEqual([<<"f_sig_single_simple_clause(Arg)">>],
get_sig({function, ?FUNCTION_NAME, 1}, Docs)).
f_sig_single_simple_clause_with_spec(Config) ->
Docs = get_docs(Config, eep48_sigs),
%?debugVal(Docs, 1000),
- ?assertEqual([?a2b(?FUNCTION_NAME),<<"(">>,<<"Arg">>,<<")">>,<<"\n">>],
+ ?assertEqual([<<"f_sig_single_simple_clause_with_spec(Arg)">>],
get_sig({function, ?FUNCTION_NAME, 1}, Docs)).
f_sig_multiple_simple_clauses(Config) ->
Docs = get_docs(Config, eep48_sigs),
%?debugVal(Docs, 1000),
- ?assertEqual([?a2b(?FUNCTION_NAME),<<"(">>,<<"C1A1, ">>,<<"C1A2">>,<<")">>,<<"\n">>],
+ ?assertEqual([<<"f_sig_multiple_simple_clauses(C1A1,">>, <<"C1A2)">>],
get_sig({function, ?FUNCTION_NAME, 2}, Docs)).
f_sig_multiple_simple_clauses_with_spec(Config) ->
Docs = get_docs(Config, eep48_sigs),
%?debugVal(Docs, 1000),
- ?assertEqual([?a2b(?FUNCTION_NAME),<<"(">>,<<"C1A1, ">>,<<"C1A2">>,<<")">>,<<"\n">>],
+ ?assertEqual([<<"f_sig_multiple_simple_clauses_with_spec(C1A1,">>, <<"C1A2)">>],
get_sig({function, ?FUNCTION_NAME, 2}, Docs)).
f_sig_single_record_clause(Config) ->
Docs = get_docs(Config, eep48_sigs),
%?debugVal(Docs, 1000),
- ?assertEqual([?a2b(?FUNCTION_NAME),<<"(">>,<<"R">>,<<")">>,<<"\n">>],
+ ?assertEqual([<<"f_sig_single_record_clause(R)">>],
get_sig({function, ?FUNCTION_NAME, 1}, Docs)).
f_sig_single_record_clause_with_spec(Config) ->
Docs = get_docs(Config, eep48_sigs),
%?debugVal(Docs, 1000),
- ?assertEqual([?a2b(?FUNCTION_NAME),<<"(">>,<<"R">>,<<")">>,<<"\n">>],
+ ?assertEqual([<<"f_sig_single_record_clause_with_spec(R)">>],
get_sig({function, ?FUNCTION_NAME, 1}, Docs)).
f_sig_multiple_record_clauses(Config) ->
Docs = get_docs(Config, eep48_sigs),
%?debugVal(Docs, 1000),
- ?assertEqual([?a2b(?FUNCTION_NAME),<<"(">>,<<"R">>,<<")">>,<<"\n">>],
+ ?assertEqual([<<"f_sig_multiple_record_clauses(R)">>],
get_sig({function, ?FUNCTION_NAME, 1}, Docs)).
f_sig_multiple_record_clauses_with_spec(Config) ->
Docs = get_docs(Config, eep48_sigs),
%?debugVal(Docs, 1000),
- ?assertEqual([?a2b(?FUNCTION_NAME),<<"(">>,<<"R">>,<<")">>,<<"\n">>],
+ ?assertEqual([<<"f_sig_multiple_record_clauses_with_spec(R)">>],
get_sig({function, ?FUNCTION_NAME, 1}, Docs)).
f_spec_type_without_name(Config) ->