diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-07-10 20:24:57 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-07-11 14:10:02 +0200 |
commit | 12bb46671a2a2835eaa4e6cfa6ddda3923d9f7e1 (patch) | |
tree | e14f64e8215f3a23f7dbdfb4464256f202fdd4b8 /lib | |
parent | 98c5cdbe60b6d743ad461b651a586c6f3a502ba9 (diff) | |
download | otp-12bb46671a2a2835eaa4e6cfa6ddda3923d9f7e1.tar.gz otp-12bb46671a2a2835eaa4e6cfa6ddda3923d9f7e1.tar.bz2 otp-12bb46671a2a2835eaa4e6cfa6ddda3923d9f7e1.zip |
erl_docgen: Add Map type information for docs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/erl_docgen/src/docgen_otp_specs.erl | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/erl_docgen/src/docgen_otp_specs.erl b/lib/erl_docgen/src/docgen_otp_specs.erl index 886194598f..cbdbbbee80 100644 --- a/lib/erl_docgen/src/docgen_otp_specs.erl +++ b/lib/erl_docgen/src/docgen_otp_specs.erl @@ -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}]) -> @@ -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), @@ -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}]) -> @@ -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)], |