Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
  • Loading branch information
psyeugenic committed Jul 15, 2014
2 parents 6f38255 + 1de92df commit adde761
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 6 deletions.
12 changes: 11 additions & 1 deletion lib/edoc/src/edoc_layout.erl
Expand Up @@ -898,7 +898,7 @@ t_map(Es) ->
["#{"] ++ seq(fun t_utype_elem/1, Es, ["}"]).

t_map_field([K,V]) ->
[t_utype_elem(K) ++ " => " ++ t_utype_elem(V)].
t_utype_elem(K) ++ [" => "] ++ t_utype_elem(V).

t_record(E, Es) ->
Name = ["#"] ++ t_type(get_elem(atom, Es)),
Expand Down Expand Up @@ -1095,6 +1095,10 @@ ot_type([#xmlElement{name = nonempty_list, content = Es}]) ->
ot_nonempty_list(Es);
ot_type([#xmlElement{name = tuple, content = Es}]) ->
ot_tuple(Es);
ot_type([#xmlElement{name = map, content = Es}]) ->
ot_map(Es);
ot_type([#xmlElement{name = map_field, content = Es}]) ->
ot_map_field(Es);
ot_type([#xmlElement{name = 'fun', content = Es}]) ->
ot_fun(Es);
ot_type([#xmlElement{name = record, content = Es}]) ->
Expand Down Expand Up @@ -1151,6 +1155,12 @@ ot_nonempty_list(Es) ->
ot_tuple(Es) ->
{type,0,tuple,[ot_utype_elem(E) || E <- Es]}.

ot_map(Es) ->
{type,0,map,[ot_utype_elem(E) || E <- Es]}.

ot_map_field(Es) ->
{type,0,map_field_assoc,[ot_utype_elem(E) || E <- Es]}.

ot_fun(Es) ->
Range = ot_utype(get_elem(type, Es)),
Args = [ot_utype_elem(A) || A <- get_content(argtypes, Es)],
Expand Down
42 changes: 41 additions & 1 deletion lib/edoc/test/edoc_SUITE_data/map_module.erl
@@ -1,6 +1,6 @@
-module(map_module).

-export([foo1/1,foo2/3]).
-export([foo1/1,foo2/3,start_child/2]).

%% @type wazzup() = integer()
%% @type some_type() = map()
Expand All @@ -25,3 +25,43 @@ foo1(#{ a:= 1, b := V}) -> V.
Map :: #{ get => 'value', 'value' => binary()}) -> binary().

foo2(Type1, {a,#{ "a" := _}}, #{get := value, value := B}) when is_map(Type1) -> B.

%% from supervisor 18.0

-type child() :: 'undefined' | pid().
-type child_id() :: term().
-type mfargs() :: {M :: module(), F :: atom(), A :: [term()] | undefined}.
-type modules() :: [module()] | 'dynamic'.
-type restart() :: 'permanent' | 'transient' | 'temporary'.
-type shutdown() :: 'brutal_kill' | timeout().
-type worker() :: 'worker' | 'supervisor'.
-type sup_ref() :: (Name :: atom())
| {Name :: atom(), Node :: node()}
| {'global', Name :: atom()}
| {'via', Module :: module(), Name :: any()}
| pid().
-type child_spec() :: #{name => child_id(), % mandatory
start => mfargs(), % mandatory
restart => restart(), % optional
shutdown => shutdown(), % optional
type => worker(), % optional
modules => modules()} % optional
| {Id :: child_id(),
StartFunc :: mfargs(),
Restart :: restart(),
Shutdown :: shutdown(),
Type :: worker(),
Modules :: modules()}.

-type startchild_err() :: 'already_present'
| {'already_started', Child :: child()} | term().
-type startchild_ret() :: {'ok', Child :: child()}
| {'ok', Child :: child(), Info :: term()}
| {'error', startchild_err()}.


-spec start_child(SupRef, ChildSpec) -> startchild_ret() when
SupRef :: sup_ref(),
ChildSpec :: child_spec() | (List :: [term()]).
start_child(Supervisor, ChildSpec) ->
{Supervisor,ChildSpec}.
23 changes: 19 additions & 4 deletions lib/erl_docgen/src/docgen_otp_specs.erl
Expand Up @@ -388,8 +388,10 @@ t_type([#xmlElement{name = nonempty_list, content = Es}]) ->
t_nonempty_list(Es);
t_type([#xmlElement{name = tuple, content = Es}]) ->
t_tuple(Es);
t_type([#xmlElement{name = map}]) ->
t_map();
t_type([#xmlElement{name = map, content = Es}]) ->
t_map(Es);
t_type([#xmlElement{name = map_field, content = Es}]) ->
t_map_field(Es);
t_type([#xmlElement{name = 'fun', content = Es}]) ->
["fun("] ++ t_fun(Es) ++ [")"];
t_type([E = #xmlElement{name = record, content = Es}]) ->
Expand Down Expand Up @@ -432,8 +434,11 @@ t_nonempty_list(Es) ->
t_tuple(Es) ->
["{"] ++ seq(fun t_utype_elem/1, Es, ["}"]).

t_map() ->
["map()"].
t_map(Es) ->
["#{"] ++ seq(fun t_utype_elem/1, Es, ["}"]).

t_map_field([K,V]) ->
[t_utype_elem(K) ++ " => " ++ t_utype_elem(V)].

t_fun(Es) ->
["("] ++ seq(fun t_utype_elem/1, get_content(argtypes, Es),
Expand Down Expand Up @@ -550,6 +555,10 @@ ot_type([#xmlElement{name = nonempty_list, content = Es}]) ->
ot_nonempty_list(Es);
ot_type([#xmlElement{name = tuple, content = Es}]) ->
ot_tuple(Es);
ot_type([#xmlElement{name = map, content = Es}]) ->
ot_map(Es);
ot_type([#xmlElement{name = map_field, content = Es}]) ->
ot_map_field(Es);
ot_type([#xmlElement{name = 'fun', content = Es}]) ->
ot_fun(Es);
ot_type([#xmlElement{name = record, content = Es}]) ->
Expand Down Expand Up @@ -606,6 +615,12 @@ ot_nonempty_list(Es) ->
ot_tuple(Es) ->
{type,0,tuple,[ot_utype_elem(E) || E <- Es]}.

ot_map(Es) ->
{type,0,map,[ot_utype_elem(E) || E <- Es]}.

ot_map_field(Es) ->
{type,0,map_field_assoc,[ot_utype_elem(E) || E <- Es]}.

ot_fun(Es) ->
Range = ot_utype(get_elem(type, Es)),
Args = [ot_utype_elem(A) || A <- get_content(argtypes, Es)],
Expand Down

0 comments on commit adde761

Please sign in to comment.