From 795def48cf6768c8f79dd8b3086098f1d45f296d Mon Sep 17 00:00:00 2001 From: Maxim Zhiburt Date: Mon, 3 Feb 2025 09:29:16 +0300 Subject: [PATCH] Update docs --- tabled/src/settings/object/mod.rs | 26 ++++++++++++++++++++- testing_table/README.md | 21 +++++++++++++++-- testing_table/src/lib.rs | 39 +++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 3 deletions(-) diff --git a/tabled/src/settings/object/mod.rs b/tabled/src/settings/object/mod.rs index 8bd2d3f9..d9309f7d 100644 --- a/tabled/src/settings/object/mod.rs +++ b/tabled/src/settings/object/mod.rs @@ -1,6 +1,30 @@ -//! This module contains a list of primitives that implement a [`Object`] trait. +//! This module contains a list of primitives that implement a [`Object`] trait.\ //! They help to locate a necessary segment on a [`Table`]. //! +//! # Example +//! +//! ``` +//! use tabled::{ +//! settings::{ +//! object::{Columns, Object, Rows}, +//! Alignment, +//! }, +//! Table, +//! }; +//! use testing_table::assert_table; +//! +//! let data = [ +//! [1, 2, 3, 4, 5], +//! [10, 20, 30, 40, 50], +//! [100, 200, 300, 400, 500], +//! ]; +//! +//! let mut table = Table::new(data); +//! table.modify(Rows::first().not(Columns::first()), Alignment::right()); +//! +//! assert_table!(table, ""); +//! ``` +//! //! [`Table`]: crate::Table mod cell; diff --git a/testing_table/README.md b/testing_table/README.md index d58bde28..1bf49764 100644 --- a/testing_table/README.md +++ b/testing_table/README.md @@ -9,9 +9,9 @@ Includes - `assert_table!` - `assert_width!` -An example. - ```rust +use testing_table::{test_table, assert_table, static_table}; + test_table!( test_tabled, tabled::Table::new([[1, 2, 3]]), @@ -21,4 +21,21 @@ test_table!( "| 1 | 2 | 3 |" "+---+---+---+" ); + +assert_table!( + tabled::Table::new([[1, 2, 3]]), + "+---+---+---+" + "| 0 | 1 | 2 |" + "+---+---+---+" + "| 1 | 2 | 3 |" + "+---+---+---+" +); + +static_table!( + "+---+---+---+" + "| 0 | 1 | 2 |" + "+---+---+---+" + "| 1 | 2 | 3 |" + "+---+---+---+" +); ``` \ No newline at end of file diff --git a/testing_table/src/lib.rs b/testing_table/src/lib.rs index 60b64d60..fc69b9f7 100644 --- a/testing_table/src/lib.rs +++ b/testing_table/src/lib.rs @@ -1,5 +1,44 @@ //! Crate provides a convinient functions for work with tables. //! +//! ```ignore +//! use testing_table::test_table; +//! +//! test_table!( +//! test_tabled, +//! tabled::Table::new([[1, 2, 3]]), +//! "+---+---+---+" +//! "| 0 | 1 | 2 |" +//! "+---+---+---+" +//! "| 1 | 2 | 3 |" +//! "+---+---+---+" +//! ); +//! ``` +//! +//! ```ignore +//! use testing_table::assert_table; +//! +//! assert_table!( +//! tabled::Table::new([[1, 2, 3]]), +//! "+---+---+---+" +//! "| 0 | 1 | 2 |" +//! "+---+---+---+" +//! "| 1 | 2 | 3 |" +//! "+---+---+---+" +//! ); +//! ``` +//! +//! ``` +//! use testing_table::static_table; +//! +//! static_table!( +//! "+---+---+---+" +//! "| 0 | 1 | 2 |" +//! "+---+---+---+" +//! "| 1 | 2 | 3 |" +//! "+---+---+---+" +//! ); +//! ``` +//! //! It was developed as a sub-project of [`tabled`]. //! //! [`tabled`]: https://github.com/zhiburt/tabled