1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! This library is designed to render text tables with possible formatting.
//!
//! There is only one entry point to this library, the [Table] struct.
//!
//! # How to use
//!
//! ## Basic Usage
//!
//! You can use the macros to quickly create a table.
//!
//! ```rust
//! use itertools::Itertools;
//! use table_formatter::{cell, table};
//! use table_formatter::table::{Align, Border};
//! let table_header = vec![
//!     cell!("Cell Row").with_width(Some(20)),
//!     cell!("Left", align = Align::Left).with_width(Some(10)),
//!     cell!("Center", align = Align::Center).with_width(Some(10)),
//!     cell!("Right", align = Align::Right).with_width(Some(10)),
//! ];
//! let table_cells = {
//!     let mut v = (0..=3_u8)
//!         .map(|_| {
//!             vec![
//!                 cell!("Cell Row"),
//!                 cell!("Left", align = Align::Left),
//!                 cell!("Center", align = Align::Center),
//!                 cell!("Right", align = Align::Right),
//!             ]
//!         })
//!         .collect_vec();
//!     v.push(cell!("Cross Cell!", align = Align::Center).with_span(3));
//!     v
//! };
//! let table = table! {
//!     table_header
//!     ---
//!     table_cells
//!     with Border::ALL
//! };
//! let mut buffer = vec![];
//! table.render(&mut buffer).unwrap();
//! println!("{}", String::from_utf8(buffer).unwrap());
//! ```
//!
//! ## Output Definition
//!
//! You can use [table::Renderer] to define the way it renders.
//!
//! For example, such code below could generate a markdown table.
//!
//! ```rust
//! # use itertools::Itertools;
//! # use table_formatter::table::{Align, Border, Renderer};
//! # use table_formatter::{cell, table};
//! let table_header = vec![
//!     cell!("Cell Row").with_width(Some(20)),
//!     cell!("Right", align = Align::Right).with_width(Some(10)),
//! ];
//! let table_cells = (0..=3_u8)
//!     .map(|_| vec![cell!("Cell Row"), cell!("Right", align = Align::Right)])
//!     .collect_vec();
//! let table = table! {
//!     table_header
//!     ---
//!     table_cells
//!     with Border::ALL
//! };
//! let mut buffer = vec![];
//! table.rendered_by(Renderer::Markdown, &mut buffer).unwrap();
//! println!("{}", String::from_utf8(buffer).unwrap());
//! ```
//! 
//! Output:
//! ```markdown
//! ┃Cell Row┃Right┃
//! ┃:--┃--:┃
//! ┃━━━┃━━━┃
//! ┃Cell Row┃Right┃
//! ┃Cell Row┃Right┃
//! ┃Cell Row┃Right┃
//! ┃Cell Row┃Right┃
//! ```
//!
//! [table::Renderer]: ../table/enum.Renderer.html
//! [Table]: ../table/struct.Table.html

pub mod builder;
pub mod error;
pub mod table;