tabletool 0.2.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(Justify.Center, Style.Markdown, 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
  • Select styles (simple, markdown and grid)
  • Select text alignment (left, center and right)
  • 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:
  • 1 downloads today

  • 2 downloads this week

  • 2 downloads this month

  • 1495 downloads total

Score:
0.6
Short URL:
tabletool.dub.pm