diff options
author | Hans Bolinder <[email protected]> | 2016-06-08 12:14:21 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2016-06-08 12:43:35 +0200 |
commit | 5e7542d6f7cd1964839f6214915c7f9b7d7f8866 (patch) | |
tree | ba277c79284ef266a220097b45f8ab4a9005c25a /lib/erl_docgen/src | |
parent | 39c6338a1b671a98cc2c8d21e9ba373816e5071a (diff) | |
download | otp-5e7542d6f7cd1964839f6214915c7f9b7d7f8866.tar.gz otp-5e7542d6f7cd1964839f6214915c7f9b7d7f8866.tar.bz2 otp-5e7542d6f7cd1964839f6214915c7f9b7d7f8866.zip |
edoc: Fix new Maps syntax
Diffstat (limited to 'lib/erl_docgen/src')
-rw-r--r-- | lib/erl_docgen/src/docgen_otp_specs.erl | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/lib/erl_docgen/src/docgen_otp_specs.erl b/lib/erl_docgen/src/docgen_otp_specs.erl index e154323f07..5bc3be7a8d 100644 --- a/lib/erl_docgen/src/docgen_otp_specs.erl +++ b/lib/erl_docgen/src/docgen_otp_specs.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2015. All Rights Reserved. +%% Copyright Ericsson AB 1996-2016. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -389,10 +389,10 @@ t_type([#xmlElement{name = list, content = Es}]) -> t_list(Es); 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, content = Es}]) -> t_map(Es); +t_type([#xmlElement{name = tuple, content = Es}]) -> + t_tuple(Es); t_type([#xmlElement{name = 'fun', content = Es}]) -> ["fun("] ++ t_fun(Es) ++ [")"]; t_type([E = #xmlElement{name = record, content = Es}]) -> @@ -435,16 +435,28 @@ t_nonempty_list(Es) -> t_tuple(Es) -> ["{"] ++ seq(fun t_utype_elem/1, Es, ["}"]). +t_fun(Es) -> + ["("] ++ seq(fun t_utype_elem/1, get_content(argtypes, Es), + [") -> "] ++ t_utype(get_elem(type, Es))). + t_map(Es) -> Fs = get_elem(map_field, Es), ["#{"] ++ seq(fun t_map_field/1, Fs, ["}"]). -t_map_field(#xmlElement{content = [K,V]}) -> - [t_utype_elem(K) ++ " => " ++ t_utype_elem(V)]. - -t_fun(Es) -> - ["("] ++ seq(fun t_utype_elem/1, get_content(argtypes, Es), - [") -> "] ++ t_utype(get_elem(type, Es))). +t_map_field(#xmlElement{content = [K,V]}=E) -> + KElem = t_utype_elem(K), + VElem = t_utype_elem(V), + AT = get_attrval(assoc_type, E), + IsAny = fun(["any","()"]) -> true; (_) -> false end, + case AT =:= "assoc" andalso IsAny(KElem) andalso IsAny(VElem) of + true -> "..."; + false -> + AS = case AT of + "assoc" -> " => "; + "exact" -> " := " + end, + KElem ++ [AS] ++ VElem + end. t_record(E, Es) -> Name = ["#"] ++ t_type(get_elem(atom, Es)), @@ -618,8 +630,12 @@ ot_tuple(Es) -> ot_map(Es) -> {type,0,map,[ot_map_field(E) || E <- get_elem(map_field,Es)]}. -ot_map_field(#xmlElement{content=[K,V]}) -> - {type,0,map_field_assoc,[ot_utype_elem(K),ot_utype_elem(V)]}. +ot_map_field(#xmlElement{content=[K,V]}=E) -> + A = case get_attrval(assoc_type, E) of + "assoc" -> map_field_assoc; + "exact" -> map_field_exact + end, + {type,0,A,[ot_utype_elem(K), ot_utype_elem(V)]}. ot_fun(Es) -> Range = ot_utype(get_elem(type, Es)), |