papergrid/
lib.rs

1#![cfg_attr(not(any(feature = "std", test)), no_std)]
2#![warn(
3    rust_2018_idioms,
4    rust_2018_compatibility,
5    rust_2021_compatibility,
6    missing_debug_implementations,
7    unreachable_pub,
8    missing_docs
9)]
10#![allow(clippy::uninlined_format_args)]
11#![deny(unused_must_use)]
12#![doc(
13    html_logo_url = "https://raw.githubusercontent.com/zhiburt/tabled/86ac146e532ce9f7626608d7fd05072123603a2e/assets/tabled-gear.svg"
14)]
15
16//! Papergrid is a library for generating text-based tables.
17//!
18//! It has relatively low level API.
19//! If you're interested in a more friendly one take a look at [`tabled`](https://github.com/zhiburt/tabled).
20//!
21//! # Example
22//!
23#![cfg_attr(feature = "std", doc = "```")]
24#![cfg_attr(not(feature = "std"), doc = "```ignore")]
25//! use papergrid::{
26//!     records::IterRecords,
27//!     dimension::{Estimate},
28//!     config::Borders,
29//!     colors::NoColors,
30//!     grid::iterable::IterGrid,
31//!     config::spanned::SpannedConfig,
32//!     dimension::iterable::IterGridDimension,
33//! };
34//!
35//! // Creating a borders structure of a grid.
36//! let borders = Borders {
37//!     top: Some('-'),
38//!     top_left: Some('+'),
39//!     top_right: Some('+'),
40//!     top_intersection: Some('+'),
41//!     bottom: Some('-'),
42//!     bottom_left: Some('+'),
43//!     bottom_right: Some('+'),
44//!     bottom_intersection: Some('+'),
45//!     horizontal: Some('-'),
46//!     vertical: Some('|'),
47//!     left: Some('|'),
48//!     right: Some('|'),
49//!     intersection: Some('+'),
50//!     left_intersection: Some('+'),
51//!     right_intersection: Some('+'),
52//! };
53//!
54//! // Creating a grid config.
55//! let mut cfg = SpannedConfig::default();
56//! cfg.set_borders(borders);
57//!
58//! // Creating an actual data for grid.
59//! let records = vec![vec!["Hello", "World"], vec!["Hi", "World"]];
60//! let records = IterRecords::new(records, 2, None);
61//!
62//! // Estimate grid dimension.
63//! let mut dims = IterGridDimension::default();
64//! dims.estimate(&records, &cfg);
65//!
66//! // Creating a grid.
67//! let grid = IterGrid::new(&records, &cfg, &dims, NoColors);
68//!
69//! assert_eq!(
70//!     grid.to_string(),
71//!     concat!(
72//!         "+-----+-----+\n",
73//!         "|Hello|World|\n",
74//!         "+-----+-----+\n",
75//!         "|Hi   |World|\n",
76//!         "+-----+-----+",
77//!     ),
78//! );
79//! ```
80
81pub mod ansi;
82pub mod colors;
83pub mod config;
84pub mod dimension;
85pub mod grid;
86pub mod records;
87pub mod util;