Acme-CPANModules-TextTable
view release on metacpan or search on metacpan
lib/Acme/CPANModules/TextTable.pm view on Meta::CPAN
$res;
}
our $LIST = {
summary => 'List of modules that generate text tables',
description => <<'_',
Currently excluded from this list are:
- <pm:Text::SimpleTable::AutoWidth> (wrapper to <pm:Text::SimpleTable>);
- <pm:Text::ASCIITable::EasyTable> (wrapper to <pm:Text::ASCIITable>);
_
entry_features => {
wide_char => {summary => 'Whether the use of wide characters (e.g. Kanji) in cells does not cause the table to be misaligned'},
color_data => {summary => 'Whether module supports ANSI colors (i.e. text with ANSI color codes can still be aligned properly)'},
multiline_data => {summary => 'Whether module supports aligning data cells that contain newlines'},
box_char => {summary => 'Whether module can utilize box-drawing characters'},
custom_border => {summary => 'Whether module allows customizing border in some way'},
align_row => {summary => "Whether module supports aligning text horizontally in a row (left/right/middle)"},
align_column => {summary => "Whether module supports aligning text horizontally in a column (left/right/middle)"},
align_cell => {summary => "Whether module supports aligning text horizontally in individual cells (left/right/middle)"},
valign_row => {summary => "Whether module supports aligning text vertically in a row (top/bottom/middle)"},
valign_column => {summary => "Whether module supports aligning text vertically in a column (top/bottom/middle)"},
valign_cell => {summary => "Whether module supports aligning text vertically in individual cells (top/bottom/middle)"},
rowspan => {summary => "Whether module supports row spans"},
colspan => {summary => "Whether module supports column spans"},
custom_color => {summary => 'Whether the module produces colored table and supports customizing color in some way'},
color_theme => {summary => 'Whether the module supports color theme/scheme'},
speed => {summary => "Rendering speed", schema=>'str*'},
column_width => {summary => 'Whether module allows setting the width of columns'},
per_column_width => {summary => 'Whether module allows setting column width on a per-column basis'},
row_height => {summary => 'Whether module allows setting the height of rows'},
per_row_height => {summary => 'Whether module allows setting row height on a per-row basis'},
pad => {summary => 'Whether module allows customizing cell horizontal padding'},
vpad => {summary => 'Whether module allows customizing cell vertical padding'},
},
entries => [
{
module => 'Text::Table::Any',
description => <<'_',
This is a frontend for many text table modules as backends. The interface is
dead simple, following <pm:Text::Table::Tiny>. The main drawback is that it
currently does not allow passing (some, any) options to each backend.
_
bench_code => sub {
my ($table) = @_;
Text::Table::Any::table(rows=>$table, header_row=>1);
},
features => {
align_cell => {value=>undef, summary=>"Depends on backend"},
align_column => {value=>undef, summary=>"Depends on backend"},
align_row => {value=>undef, summary=>"Depends on backend"},
box_char => {value=>undef, summary=>"Depends on backend"},
color_data => {value=>undef, summary=>"Depends on backend"},
color_theme => {value=>undef, summary=>"Depends on backend"},
colspan => {value=>undef, summary=>"Depends on backend"},
custom_border => {value=>undef, summary=>"Depends on backend"},
custom_color => {value=>undef, summary=>"Depends on backend"},
multiline_data => {value=>undef, summary=>"Depends on backend"},
rowspan => {value=>undef, summary=>"Depends on backend"},
speed => {value=>undef, summary=>"Depends on backend"},
valign_cell => {value=>undef, summary=>"Depends on backend"},
valign_column => {value=>undef, summary=>"Depends on backend"},
valign_row => {value=>undef, summary=>"Depends on backend"},
wide_char_data => {value=>undef, summary=>"Depends on backend"},
},
},
{
module => 'Text::SimpleTable',
description => <<'_',
As its name implies, a simple table-generating module with minimal documentation
and a few choices or border characters. You have to set the width of all columns
manually.
_
bench_code => sub {
my ($table) = @_;
my @colspec = map {[9, $_]} @{ $table->[0] };
my $ts = Text::SimpleTable->new(@colspec);
for (1 .. $#{$table}) { $ts->row(@{ $table->[$_] }) }
$ts->draw;
},
features => {
align_cell => {value=>0},
align_column => {value=>0},
align_row => {value=>0},
box_char => {value=>0},
color_data => {value=>0},
color_theme => {value=>0},
colspan => {value=>0},
custom_border => {value=>1, summary=>"Limited choice of 1 ASCII style and 1 UTF style"},
custom_color => {value=>0},
multiline_data => {value=>0},
rowspan => {value=>0},
speed => {value=>'fast', summary=>'Slightly slower than Text::Table::Tiny'},
valign_cell => {value=>0},
valign_column => {value=>0},
valign_row => {value=>0},
wide_char_data => {value=>0},
},
},
{
module => 'Text::UnicodeBox::Table',
description => <<'_',
The main feature of this module is the various border style it provides drawn
using Unicode box-drawing characters. It allows per-row style. The rendering
speed is particularly slow compared to other modules.
_
bench_code => sub {
my ($table) = @_;
my $t = Text::UnicodeBox::Table->new;
$t->add_header(@{ $table->[0] });
$t->add_row(@{ $table->[$_] }) for 1..$#{$table};
$t->render;
},
features => {
align_cell => 0,
align_column => 1,
box_char => 0,
color_data => 1,
color_theme => 0,
colspan => 0,
custom_border => 1,
custom_color => 0,
multiline_data => 0,
rowspan => 0,
wide_char_data => 1,
speed => "slow",
},
},
{
module => 'Text::Table::Manifold',
description => <<'_',
Two main features of this module is per-column aligning and wide character
support. This module, aside from doing its rendering, can also be told to pass
rendering to HTML, CSV, or other text table module like
<pm:Text::UnicodeBox::Table>); so in this way it is similar to
<pm:Text::Table::Any>.
_
bench_code => sub {
my ($table) = @_;
my $t = Text::Table::Manifold->new;
$t->headers($table->[0]);
$t->data([ @{$table}[1 .. $#{$table}] ]);
join("\n", @{$t->render(padding => 1)}) . "\n";
},
features => {
align_cell => 0,
align_column => 1,
box_char => undef, # ?
color_data => 1,
color_theme => 0,
colspan => 0,
custom_border => {value=>0, summary=>"But this module can pass rendering to other module like Text::UnicodeBox::Table"},
custom_color => 0,
multiline_data => 0,
rowspan => 0,
wide_char_data => 1,
},
},
{
module => 'Text::ANSITable',
description => <<'_',
This 2013 project was my take in creating a text table module that can handle
color, multiline text, wide characters. I also threw in various formatting
options, e.g. per-column/row/cell align/valign/pad/vpad, conditional formatting,
and so on. I even added a couple of features I never used: hiding rows and
specifying columns to display which can be in different order from the original
specified columns or can contain the same original columns multiple times. I
think this module offers the most formatting options on CPAN.
In early 2021, I needed colspan/rowspan and I implemented this in a new module:
<pm:Text::Table::Span> (later renamed to <pm:Text::Table::More>). I plan to add
this feature too to Text::ANSITable, but in the meantime I'm also adding more
formatting options which I need to Text::Table::More.
_
bench_code => sub {
my ($table) = @_;
my $t = Text::ANSITable->new(
use_utf8 => 0,
use_box_chars => 0,
use_color => 0,
columns => $table->[0],
border_style => 'ASCII::SingleLine',
);
$t->add_row($table->[$_]) for 1..@$table-1;
$t->draw;
},
features => {
align_cell => 1,
align_column => 1,
align_row => 1,
box_char => 1,
color_data => 1,
color_theme => 1,
colspan => 0,
column_width => 1,
custom_border => 1,
custom_color => 1,
multiline_data => 1,
pad => 1,
per_column_width => 1,
per_row_height => 1,
row_height => 1,
rowspan => 0,
speed => "slow",
valign_cell => 1,
lib/Acme/CPANModules/TextTable.pm view on Meta::CPAN
$t->addRow(@{ $table->[$_] }) for 1..@$table-1;
"$t";
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => 0,
multiline_data => 1,
},
},
{
module => 'Text::FormatTable',
bench_code => sub {
my ($table) = @_;
my $t = Text::FormatTable->new(join('|', ('l') x @{ $table->[0] }));
$t->head(@{ $table->[0] });
$t->row(@{ $table->[$_] }) for 1..@$table-1;
$t->render;
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => 0,
multiline_data => 1,
},
},
{
module => 'Text::MarkdownTable',
bench_code => sub {
my ($table) = @_;
my $out = "";
my $t = Text::MarkdownTable->new(file => \$out);
my $fields = $table->[0];
foreach (1..@$table-1) {
my $row = $table->[$_];
$t->add( {
map { $fields->[$_] => $row->[$_] } 0..@$fields-1
});
}
$t->done;
$out;
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => 0,
multiline_data => {value=>0, summary=>'Newlines stripped'},
},
},
{
module => 'Text::Table',
bench_code => sub {
my ($table) = @_;
my $t = Text::Table->new(@{ $table->[0] });
$t->load(@{ $table }[1..@$table-1]);
$t;
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => {value=>undef, summary=>'Does not draw borders'},
multiline_data => 1,
},
},
{
module => 'Text::Table::Tiny',
description => <<'_',
The simple and tiny table-generating module which I liked back in 2012 (v0.03).
It employs an sprintf() trick to generate a single row. This module started my
personal experiments creating other table-generating modules (at last count I've
created no fewer than 15 of them!).
_
bench_code => sub {
my ($table) = @_;
Text::Table::Tiny::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 1,
color_data => 1,
box_char => 1,
multiline_data => 0,
},
},
{
module => 'Text::Table::TinyBorderStyle',
bench_code => sub {
my ($table) = @_;
Text::Table::TinyBorderStyle::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => 1,
multiline_data => 0,
},
},
{
module => 'Text::Table::More',
description => <<'_',
A module I wrote in early 2021. Main distinguishing feature is support for
rowspan/clospan. I plan to add more features to this module on an as-needed
basic. This module is now preferred to <pm:Text::ANSITable>, although currently
it does not offer nearly as many formatting options as Text::ANSITable.
_
bench_code => sub {
my ($table) = @_;
Text::Table::More::generate_table(rows=>$table, header_row=>1);
},
features => {
align_cell => 1,
align_column => 1,
align_row => 1,
box_char => 1,
color_data => 1,
color_theme => 0,
colspan => 1,
custom_border => 1,
lib/Acme/CPANModules/TextTable.pm view on Meta::CPAN
{
module => 'Text::Table::TinyColor',
bench_code => sub {
my ($table) = @_;
Text::Table::TinyColor::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 0,
color_data => 1,
box_char => 0,
multiline_data => 0,
},
},
{
module => 'Text::Table::TinyColorWide',
bench_code => sub {
my ($table) = @_;
Text::Table::TinyColorWide::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 1,
color_data => 1,
box_char => 0,
multiline_data => 0,
},
},
{
module => 'Text::Table::TinyWide',
bench_code => sub {
my ($table) = @_;
Text::Table::TinyWide::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 1,
color_data => 0,
box_char => 0,
},
},
{
module => 'Text::Table::Org',
bench_code => sub {
my ($table) = @_;
Text::Table::Org::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => 0,
multiline_data => 0,
},
},
{
module => 'Text::Table::CSV',
bench_code => sub {
my ($table) = @_;
Text::Table::CSV::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 1,
color_data => 0,
box_char => {value=>undef, summary=>"Irrelevant"},
multiline_data => {value=>1, summary=>"But make sure your CSV parser can handle multiline cell"},
},
},
{
module => 'Text::Table::HTML',
bench_code => sub {
my ($table) = @_;
Text::Table::HTML::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 1,
color_data => {value=>0, summary=>'Not converted to HTML color elements'},
box_char => 0,
multiline_data => 1,
},
},
{
module => 'Text::Table::HTML::DataTables',
bench_code => sub {
my ($table) = @_;
Text::Table::HTML::DataTables::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 1,
color_data => {value=>0, summary=>'Not converted to HTML color elements'},
box_char => 0,
multiline_data => 1,
},
},
{
module => 'Text::TabularDisplay',
bench_code => sub {
my ($table) = @_;
my $t = Text::TabularDisplay->new(@{ $table->[0] });
$t->add(@{ $table->[$_] }) for 1..@$table-1;
$t->render; # doesn't add newline
},
features => {
wide_char_data => 1,
color_data => 0,
box_char => {value=>undef, summary=>"Irrelevant"},
multiline_data => 1,
},
},
],
bench_datasets => [
{name=>'tiny (1x1)' , argv => [_make_table( 1, 1)],},
{name=>'small (3x5)' , argv => [_make_table( 3, 5)],},
{name=>'wide (30x5)' , argv => [_make_table(30, 5)],},
{name=>'long (3x300)' , argv => [_make_table( 3, 300)],},
{name=>'large (30x300)' , argv => [_make_table(30, 300)],},
{name=>'multiline data (2x1)', argv => [ [["col1", "col2"], ["foobar\nbaz\nqux\nquux","corge"]] ], include_by_default=>0 },
{name=>'wide char data (1x2)', argv => [ [["col1"], ["no wide character"], ["宽å"]] ], include_by_default=>0 },
{name=>'color data (1x2)' , argv => [ [["col1"], ["no color"], ["\e[31m\e[1mwith\e[0m \e[32m\e[1mcolor\e[0m"]] ], include_by_default=>0 },
],
};
1;
# ABSTRACT: List of modules that generate text tables
__END__
=pod
=encoding UTF-8
=head1 NAME
Acme::CPANModules::TextTable - List of modules that generate text tables
=head1 VERSION
This document describes version 0.016 of Acme::CPANModules::TextTable (from Perl distribution Acme-CPANModules-TextTable), released on 2023-10-31.
=head1 SYNOPSIS
To run benchmark with default option:
% bencher --cpanmodules-module TextTable
To run module startup overhead benchmark:
% bencher --module-startup --cpanmodules-module TextTable
For more options (dump scenario, list/include/exclude/add participants, list/include/exclude/add datasets, etc), see L<bencher> or run C<bencher --help>.
=head1 DESCRIPTION
Currently excluded from this list are:
=over
=item * L<Text::SimpleTable::AutoWidth> (wrapper to L<Text::SimpleTable>);
=item * L<Text::ASCIITable::EasyTable> (wrapper to L<Text::ASCIITable>);
=back
=head1 ACME::CPANMODULES ENTRIES
( run in 1.002 second using v1.01-cache-2.11-cpan-d80b1682f3f )