Usage
-
Implement
Table
trait for your custom type by defining therow
method which returns the type as aVec
<
String
>
. -
Create a
Veg
struct with a header definition based on a Markdown table header. -
Use the
Veg
struct like aVec
to gather instances of your type. -
Call one of the following methods to generate a table:
markdown
: Markdown table using the initial header definitionmarkdown_with
: Markdown table using a custom header definition and/or column indexes
Example
// Import Veg
# use anyhow;
use Veg;
// Create a custom type
// Implement a method that creates a Box of the custom type
// Implement the veg::Table::row method to define how to print the custom type
// Create a Veg via the table method with a header definition
let mut v = table;
// Add a single point
v.push;
// Add a bunch of points
v.append;
// Render as a markdown table
assert_eq!;
// Render as a markdown table with a modified header definition
assert_eq!;
// Render as a markdown table with a modified header definition to increase the
// column widths
assert_eq!;
// Just render the second column
assert_eq!;
// Reorder the columns
assert_eq!;
// Duplicate column `y`
assert_eq!;
// Try to give invalid column indexes
assert_eq!;
Features
colored
The colored
feature enables the veg::colored
module which provides the
same API, but uses the colored
crate to colorize Veg
tables for printing
to the terminal.
See tests/colored.rs
and/or run
cargo test --features colored --test colored -- --nocapture
.
Changelog
- 0.1.0 (2023-12-11): Initial release
- 0.1.1 (2023-12-11): Add makefile, changelog; fix readme, clippy
- 0.2.0 (2023-12-11): Convert the table function to a method
- 0.2.1 (2023-12-11): Fix readme
- 0.3.0 (2023-12-12): Enable single column tables; add the
markdown_with
method to enable column subsets, reordering, duplicating, and temporary headers; add examples to the module doctest - 0.4.0 (2023-12-16): Add
colored
feature/module enabling terminal colors via thecolored
crate- 0.4.1 (2023-12-16): Fix changelog
- 0.4.2 (2023-12-17): Improve readme, doc, and tests
- 0.4.3 (2023-12-17): Add doc for colored module; make the colored png smaller; improve doc
- 0.4.4 (2023-12-17): Fix colored module doc
- 0.4.5 (2023-12-17): Fix doc
- 0.4.6 (2023-12-18): Fix veg::colored::Veg::table argument type
- 0.4.7 (2023-12-18): Add
Veg::is_empty
methods - 0.4.8 (2024-01-06): Fix empty string find unwrap issue; update dependencies
- 0.5.0 (2024-03-10): Fix Unicode text width algorithm; update dependencies