tabletool 0.4.0

A table generator library inspired by Python's tabulate compatible with east-asian character


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

tabletool

test DUB

A table generator library inspired by Python's tabulate compatible with east-asian character.

import std.stdio;
import tabletool;

const data = [
    ["D-man", "Programming Language"],
    ["D言語くん", "プログラミング言語"],
];
const header = ["マスコットキャラクタ", "about"];
writeln(tabulate(data, header));
/* Output:
 マスコットキャラクタ          about         
---------------------- ----------------------
        D-man           Programming Language 
      D言語くん          プログラミング言語  
*/

// Also works with struct
struct Data {
    @DisplayName("マスコットキャラクタ")
    string name;
    string about;
}

const structData = [
    Data("D-man", "Programming Language"),
    Data("D言語くん", "プログラミング言語"),
];
writeln(tabulate(structData));
/* Output: ditto */

writeln(tabulate(structData, Config(Style.grid, Align.left, true)));
/* Output:
┌──────────────────────┬──────────────────────┐
│ マスコットキャラクタ │ about                │
├──────────────────────┼──────────────────────┤
│ D-man                │ Programming Language │
├──────────────────────┼──────────────────────┤
│ D言語くん            │ プログラミング言語   │
└──────────────────────┴──────────────────────┘
*/

Features

  • Compatible with east-asian characters (Thank to eastasianwidth)
  • Generate a table from 2-D array of any element which can be converted to string
  • Generate a table from 1-D array of a struct (Can override display name by UDA @DisplayName("<name>"))
  • Generate a table from 1-D array of an associated array whose key and value can be converted to string
  • Configure table appearance (style, alginment
  • Turn on/off header
Authors:
  • nonanonno
Dependencies:
east_asian_width
Versions:
0.5.0 2023-May-20
0.4.0 2023-May-16
0.3.0 2022-Dec-11
0.2.0 2022-Sep-24
0.1.1 2022-Sep-24
Show all 7 versions
Download Stats:
  • 0 downloads today

  • 8 downloads this week

  • 147 downloads this month

  • 2014 downloads total

Score:
2.4
Short URL:
tabletool.dub.pm