@@ -35,6 +35,54 @@ Tables.columns(t::LabeledTable) = Tables.columns(t.table)
3535
3636Tables. columnnames (t:: LabeledTable ) = Tables. columnnames (t. table)
3737
38+ # -----------
39+ # IO METHODS
40+ # -----------
41+
42+ function Base. summary (io:: IO , t:: LabeledTable )
43+ name = nameof (typeof (t))
44+ nlab = length (t. labels)
45+ print (io, " $name with $nlab label(s)" )
46+ end
47+
48+ Base. show (io:: IO , t:: LabeledTable ) = summary (io, t)
49+
50+ function Base. show (io:: IO , :: MIME"text/plain" , t:: LabeledTable )
51+ pretty_table (io, t; backend= :text , _common_kwargs (t)... )
52+ end
53+
54+ function Base. show (io:: IO , :: MIME"text/html" , t:: LabeledTable )
55+ pretty_table (
56+ io,
57+ t;
58+ backend= :html ,
59+ _common_kwargs (t)... ,
60+ renderer= :show ,
61+ style= HtmlTableStyle (title= [" font-size" => " 14px" ])
62+ )
63+ end
64+
65+ function _common_kwargs (t)
66+ cols = Tables. columns (t)
67+ vars = Tables. columnnames (cols)
68+
69+ labels = map (vars) do var
70+ if var ∈ t. labels
71+ styled " {(weight=bold),magenta:$var}"
72+ else
73+ styled " {(weight=bold):$var}"
74+ end
75+ end
76+
77+ (
78+ title= summary (t),
79+ column_labels= collect (labels),
80+ maximum_number_of_rows= 10 ,
81+ new_line_at_end= false ,
82+ alignment= :c
83+ )
84+ end
85+
3886"""
3987 label(table, names)
4088
0 commit comments