diff --git a/src/flatten.rs b/src/flatten.rs index 31de7bb..0184677 100644 --- a/src/flatten.rs +++ b/src/flatten.rs @@ -1,6 +1,9 @@ use crate::identifier::{TreeIdentifier, TreeIdentifierVec}; use crate::TreeItem; +/// A flattened item of all visible [`TreeItem`s](TreeItem). +/// +/// Generated via [`flatten`]. pub struct Flattened<'a> { pub identifier: Vec, pub item: &'a TreeItem<'a>, @@ -13,7 +16,7 @@ impl<'a> Flattened<'a> { } } -/// Get a flat list of all visible [`TreeItem`s](TreeItem) +/// Get a flat list of all visible [`TreeItem`s](TreeItem). #[must_use] pub fn flatten<'a>(opened: &[TreeIdentifierVec], items: &'a [TreeItem<'a>]) -> Vec> { internal(opened, items, &[]) diff --git a/src/identifier.rs b/src/identifier.rs index 3a67da5..b3ea9c6 100644 --- a/src/identifier.rs +++ b/src/identifier.rs @@ -5,7 +5,7 @@ pub type TreeIdentifier<'a> = &'a [usize]; /// Reference to a [`TreeItem`](crate::TreeItem) in a [`Tree`](crate::Tree) pub type TreeIdentifierVec = Vec; -/// Split a [`TreeIdentifier`] into its branch and leaf +/// Split a [`TreeIdentifier`] into its branch and leaf. /// /// # Examples /// diff --git a/src/lib.rs b/src/lib.rs index 80c2f08..ca6a5d2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,12 @@ #![forbid(unsafe_code)] +/*! +Widget built to show Tree Data structures. + +Tree widget [`Tree`] is generated with [`TreeItem`s](TreeItem) (which itself can contain [`TreeItem`] children to form the tree structure). +The user interaction state (like the current selection) is stored in the [`TreeState`]. +*/ + use std::collections::HashSet; use ratatui::buffer::Buffer; @@ -17,7 +24,7 @@ pub use crate::identifier::{ get_without_leaf as get_identifier_without_leaf, TreeIdentifier, TreeIdentifierVec, }; -/// Keeps the state of what is currently selected and what was opened in a [`Tree`] +/// Keeps the state of what is currently selected and what was opened in a [`Tree`]. /// /// # Example /// @@ -198,7 +205,7 @@ impl TreeState { } } -/// One item inside a [`Tree`] +/// One item inside a [`Tree`]. /// /// Can have zero or more `children`. /// @@ -272,7 +279,7 @@ impl<'a> TreeItem<'a> { } } -/// A `Tree` which can be rendered +/// A `Tree` which can be rendered. /// /// # Example ///