Debian Codegraph @

upstream/debian-unstable/man3/Term::Table.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "Term::Table 3perl"
58 .TH Term::Table 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 Term::Table \- Format a header and rows into a table
65 .SH DESCRIPTION
66 .IX Header "DESCRIPTION"
67 This is used by some failing tests to provide diagnostics about what has gone
68 wrong. This module is able to format rows of data into tables.
69 .SH SYNOPSIS
70 .IX Header "SYNOPSIS"
71 .Vb 1
72 \& use Term::Table;
73 \&
74 \& my $table = Term::Table\->new(
75 \& max_width => 80, # Defaults to terminal size
76 \& pad => 4, # Extra padding between table and max\-width (defaults to 4)
77 \& allow_overflow => 0, # Default is 0, when off an exception will be thrown if the table is too big
78 \& collapse => 1, # Do not show empty columns
79 \&
80 \& header => [\*(Aqname\*(Aq, \*(Aqage\*(Aq, \*(Aqhair color\*(Aq],
81 \& rows => [
82 \& [\*(AqFred Flintstone\*(Aq, 2000000, \*(Aqblack\*(Aq],
83 \& [\*(AqWilma Flintstone\*(Aq, 1999995, \*(Aqred\*(Aq],
84 \& ...
85 \& ],
86 \& );
87 \&
88 \& say $_ for $table\->render;
89 .Ve
90 .PP
91 This prints a table like this:
92 .PP
93 .Vb 7
94 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+
95 \& | name | age | hair color |
96 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+
97 \& | Fred Flintstone | 2000000 | black |
98 \& | Wilma Flintstone | 1999995 | red |
99 \& | ... | ... | ... |
100 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+
101 .Ve
102 .SH INTERFACE
103 .IX Header "INTERFACE"
104 .Vb 2
105 \& use Term::Table;
106 \& my $table = Term::Table\->new(...);
107 .Ve
108 .SS OPTIONS
109 .IX Subsection "OPTIONS"
110 .IP "header => [ ... ]" 4
111 .IX Item "header => [ ... ]"
112 If you want a header specify it here.
113 This takes an arrayref with each columns heading.
114 .IP "rows => [ [...], [...], ... ]" 4
115 .IX Item "rows => [ [...], [...], ... ]"
116 This should be an arrayref containing an arrayref per row.
117 .ie n .IP "collapse => $bool" 4
118 .el .IP "collapse => \f(CW$bool\fR" 4
119 .IX Item "collapse => $bool"
120 Use this if you want to hide empty columns, that is any column that has no data
121 in any row. Having a header for the column will not effect collapse.
122 .ie n .IP "max_width => $num" 4
123 .el .IP "max_width => \f(CW$num\fR" 4
124 .IX Item "max_width => $num"
125 Set the maximum width of the table, the table may not be this big, but it will
126 be no bigger. If none is specified it will attempt to find the width of your
127 terminal and use that, otherwise it falls back to the terminal width or \f(CW80\fR.
128 .ie n .IP "pad => $num" 4
129 .el .IP "pad => \f(CW$num\fR" 4
130 .IX Item "pad => $num"
131 Defaults to \f(CW4\fR, extra padding for row width calculations.
132 Default is for legacy support.
133 Set this to \f(CW0\fR to turn padding off.
134 .ie n .IP "allow_overflow => $bool" 4
135 .el .IP "allow_overflow => \f(CW$bool\fR" 4
136 .IX Item "allow_overflow => $bool"
137 Defaults to \f(CW0\fR. If this is off then an exception will be thrown if the table
138 cannot be made to fit inside the max-width. If this is set to \f(CW1\fR then the
139 table will be rendered anyway, larger than max-width, if it is not possible
140 to stay within the max-width. In other words this turns max-width from a
141 hard-limit to a soft recommendation.
142 .ie n .IP "sanitize => $bool" 4
143 .el .IP "sanitize => \f(CW$bool\fR" 4
144 .IX Item "sanitize => $bool"
145 This will sanitize all the data in the table such that newlines, control
146 characters, and all whitespace except for ASCII 20 \f(CW\*(Aq \*(Aq\fR are replaced with
147 escape sequences. This prevents newlines, tabs, and similar whitespace from
148 disrupting the table.
149 .Sp
150 \&\fBNote:\fR newlines are marked as \f(CW\*(C`\en\*(C'\fR, but a newline is also inserted into the
151 data so that it typically displays in a way that is useful to humans.
152 .Sp
153 Example:
154 .Sp
155 .Vb 1
156 \& my $field = "foo\enbar\enbaz\en";
157 \&
158 \& print join "\en" => table(
159 \& sanitize => 1,
160 \& rows => [
161 \& [$field, \*(Aqcol2\*(Aq ],
162 \& [\*(Aqrow2 col1\*(Aq, \*(Aqrow2 col2\*(Aq]
163 \& ]
164 \& );
165 .Ve
166 .Sp
167 Prints:
168 .Sp
169 .Vb 7
170 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
171 \& | foo\en | col2 |
172 \& | bar\en | |
173 \& | baz\en | |
174 \& | | |
175 \& | row2 col1 | row2 col2 |
176 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
177 .Ve
178 .Sp
179 So it marks the newlines by inserting the escape sequence, but it also shows
180 the data across as many lines as it would normally display.
181 .ie n .IP "mark_tail => $bool" 4
182 .el .IP "mark_tail => \f(CW$bool\fR" 4
183 .IX Item "mark_tail => $bool"
184 This will replace the last whitespace character of any trailing whitespace with
185 its escape sequence. This makes it easier to notice trailing whitespace when
186 comparing values.
187 .ie n .IP "show_header => $bool" 4
188 .el .IP "show_header => \f(CW$bool\fR" 4
189 .IX Item "show_header => $bool"
190 Set this to false to hide the header. This defaults to true if the header is
191 set, false if no header is provided.
192 .ie n .IP "auto_columns => $bool" 4
193 .el .IP "auto_columns => \f(CW$bool\fR" 4
194 .IX Item "auto_columns => $bool"
195 Set this to true to automatically add columns that are not named in the header.
196 This defaults to false if a header is provided, and defaults to true when there
197 is no header.
198 .ie n .IP "no_collapse => [ $col_num_a, $col_num_b, ... ]" 4
199 .el .IP "no_collapse => [ \f(CW$col_num_a\fR, \f(CW$col_num_b\fR, ... ]" 4
200 .IX Item "no_collapse => [ $col_num_a, $col_num_b, ... ]"
201 .PD 0
202 .ie n .IP "no_collapse => [ $col_name_a, $col_name_b, ... ]" 4
203 .el .IP "no_collapse => [ \f(CW$col_name_a\fR, \f(CW$col_name_b\fR, ... ]" 4
204 .IX Item "no_collapse => [ $col_name_a, $col_name_b, ... ]"
205 .ie n .IP "no_collapse => { $col_num_a => 1, $col_num_b => 1, ... }" 4
206 .el .IP "no_collapse => { \f(CW$col_num_a\fR => 1, \f(CW$col_num_b\fR => 1, ... }" 4
207 .IX Item "no_collapse => { $col_num_a => 1, $col_num_b => 1, ... }"
208 .ie n .IP "no_collapse => { $col_name_a => 1, $col_name_b => 1, ... }" 4
209 .el .IP "no_collapse => { \f(CW$col_name_a\fR => 1, \f(CW$col_name_b\fR => 1, ... }" 4
210 .IX Item "no_collapse => { $col_name_a => 1, $col_name_b => 1, ... }"
211 .PD
212 Specify (by number and/or name) columns that should not be removed when empty.
213 The 'name' form only works when a header is specified. There is currently no
214 protection to insure that names you specify are actually in the header, invalid
215 names are ignored, patches to fix this will be happily accepted.
216 .SH "NOTE ON UNICODE/WIDE CHARACTERS"
217 .IX Header "NOTE ON UNICODE/WIDE CHARACTERS"
218 Some unicode characters, such as \f(CW\*(C`婧\*(C'\fR (\f(CW\*(C`U+5A67\*(C'\fR) are wider than others. These
219 will render just fine if you \f(CW\*(C`use utf8;\*(C'\fR as necessary, and
220 Unicode::GCString is installed, however if the module is not installed there
221 will be anomalies in the table:
222 .PP
223 .Vb 7
224 \& +\-\-\-\-\-+\-\-\-\-\-+\-\-\-+
225 \& | a | b | c |
226 \& +\-\-\-\-\-+\-\-\-\-\-+\-\-\-+
227 \& | 婧 | x | y |
228 \& | x | y | z |
229 \& | x | 婧 | z |
230 \& +\-\-\-\-\-+\-\-\-\-\-+\-\-\-+
231 .Ve
232 .SH SOURCE
233 .IX Header "SOURCE"
234 The source code repository for \f(CW\*(C`Term\-Table\*(C'\fR can be found at
235 <https://github.com/exodist/Term\-Table/>.
236 .SH MAINTAINERS
237 .IX Header "MAINTAINERS"
238 .IP "Chad Granum <[email protected]>" 4
239 .IX Item "Chad Granum <[email protected]>"
240 .SH AUTHORS
241 .IX Header "AUTHORS"
242 .PD 0
243 .IP "Chad Granum <[email protected]>" 4
244 .IX Item "Chad Granum <[email protected]>"
245 .PD
246 .SH COPYRIGHT
247 .IX Header "COPYRIGHT"
248 Copyright 2016 Chad Granum <[email protected]>.
249 .PP
250 This program is free software; you can redistribute it and/or
251 modify it under the same terms as Perl itself.
252 .PP
253 See <https://dev.perl.org/licenses/>