Skip to content

Commit d426c32

Browse files
authored
Merge pull request #7502 from garazdawi/lukas/stdlib/fix-shell-docs-multi-clause/OTP-18683
Fix shell docs multi clause
2 parents da52914 + 76342b1 commit d426c32

File tree

92 files changed

+3115
-505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+3115
-505
lines changed

lib/stdlib/src/shell_docs.erl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,18 @@ render_function(FDocs, D, Config) when is_map(Config) ->
595595
render_function(FDocs, #docs_v1{ docs = Docs } = D, Config) ->
596596
Grouping =
597597
lists:foldl(
598-
fun({_Group,_Anno,_Sig,_Doc,#{ equiv := Group }} = Func,Acc) ->
599-
Members = maps:get(Group, Acc, []),
600-
Acc#{ Group => [Func|Members] };
598+
fun({_Group,_Anno,_Sig,_Doc,#{ equiv := Group }} = Func, Acc) ->
599+
case lists:keytake(Group, 1, Acc) of
600+
false -> [{Group, [Func]} | Acc];
601+
{value, {Group, Members}, NewAcc} ->
602+
[{Group,[Func|Members]} | NewAcc]
603+
end;
601604
({Group, _Anno, _Sig, _Doc, _Meta} = Func, Acc) ->
602-
Members = maps:get(Group, Acc, []),
603-
Acc#{ Group => [Func|Members] }
604-
end, #{}, lists:sort(FDocs)),
605+
[{Group, [Func]} | Acc]
606+
end, [],
607+
%% We sort only on the group element, so that multiple entries with
608+
%% the same group do not change order. For example erlang:halt/1.
609+
lists:sort(fun(A, B) -> element(1, A) =< element(1, B) end, FDocs)),
605610
lists:map(
606611
fun({Group,Members}) ->
607612
Signatures = lists:flatmap(fun render_signature/1, lists:reverse(Members)),
@@ -621,7 +626,7 @@ render_function(FDocs, #docs_v1{ docs = Docs } = D, Config) ->
621626
Signatures, get_local_doc(Group, Doc, D), D, Config)
622627
end
623628
end
624-
end, maps:to_list(Grouping)).
629+
end, lists:reverse(Grouping)).
625630

626631
%% Render the signature of either function, type, or anything else really.
627632
render_signature({{_Type,_F,_A},_Anno,_Sigs,_Docs,#{ signature := Specs } = Meta}) ->

lib/stdlib/test/shell_docs_SUITE_data/erlang.docs_v1

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/stdlib/test/shell_docs_SUITE_data/file.docs_v1

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/stdlib/test/shell_docs_SUITE_data/kernel_file.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120

121121
• estale - Stale remote file handle
122122

123-
• exdev - Cross-domain link
123+
• exdev - Cross-device link
124124

125125
Performance
126126

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
-type fd() :: #file_descriptor{}.
2+
  fd()
33

44
A file descriptor representing a file opened in raw mode.

lib/stdlib/test/shell_docs_SUITE_data/kernel_file_mode_0_type.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
 Delay :: non_neg_integer()} |
77
 delayed_write |
88
 {read_ahead, Size :: pos_integer()} |
9-
 read_ahead | compressed |
9+
 read_ahead | compressed | compressed_one |
1010
 {encoding, unicode:encoding()} |
1111
 sync.
1212

lib/stdlib/test/shell_docs_SUITE_data/kernel_file_open_2_func.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@
113113
read_file_info/1 does probably not match the number of bytes
114114
that can be read from a compressed file.
115115

116+
compressed_one:
117+
Read one member of a gzip compressed file. Option 
118+
compressed_one can only be combined with read.
119+
116120
{encoding, Encoding}:
117121
Makes the file perform automatic translation of characters to
118122
and from a specific (Unicode) encoding. Notice that the data

lib/stdlib/test/shell_docs_SUITE_data/kernel_file_pid2name_1_func.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
-spec pid2name(Pid) -> {ok, Filename} | undefined
33
 when Filename :: filename_all(), Pid :: pid().
44

5+
Deprecated:
6+
file:pid2name/1 is deprecated and will be removed in OTP 27; this
7+
functionality is no longer supported
8+
9+
Change:
10+
This function is deprecated and will be removed in Erlang/OTP
11+
27.
12+
513
If Pid is an I/O device, that is, a pid returned from open/2,
614
this function returns the filename, or rather:
715

lib/stdlib/test/shell_docs_SUITE_data/kernel_file_type.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ These types are documented in this module:
44

55
-type deep_list() :: [char() | atom() | deep_list()].
66

7-
-type fd() :: #file_descriptor{}.
7+
  fd()
88

99
-type filename() :: string().
1010

@@ -45,7 +45,7 @@ These types are documented in this module:
4545
 Delay :: non_neg_integer()} |
4646
 delayed_write |
4747
 {read_ahead, Size :: pos_integer()} |
48-
 read_ahead | compressed |
48+
 read_ahead | compressed | compressed_one |
4949
 {encoding, unicode:encoding()} |
5050
 sync.
5151

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
  callback_mode/0
3+
4+
The documentation for callback_mode/0 is hidden. This probably
5+
means that it is internal and not to be used by other
6+
applications.

0 commit comments

Comments
 (0)