From 5e7542d6f7cd1964839f6214915c7f9b7d7f8866 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Wed, 8 Jun 2016 12:14:21 +0200 Subject: edoc: Fix new Maps syntax --- lib/edoc/src/edoc_layout.erl | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'lib/edoc/src/edoc_layout.erl') diff --git a/lib/edoc/src/edoc_layout.erl b/lib/edoc/src/edoc_layout.erl index f723cd8373..e86d090b13 100644 --- a/lib/edoc/src/edoc_layout.erl +++ b/lib/edoc/src/edoc_layout.erl @@ -898,8 +898,20 @@ 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_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)), @@ -1133,8 +1145,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)), -- cgit v1.2.3