docs: improve doc comments
This commit is contained in:
+4
-1
@@ -1,6 +1,9 @@
|
|||||||
use crate::identifier::{TreeIdentifier, TreeIdentifierVec};
|
use crate::identifier::{TreeIdentifier, TreeIdentifierVec};
|
||||||
use crate::TreeItem;
|
use crate::TreeItem;
|
||||||
|
|
||||||
|
/// A flattened item of all visible [`TreeItem`s](TreeItem).
|
||||||
|
///
|
||||||
|
/// Generated via [`flatten`].
|
||||||
pub struct Flattened<'a> {
|
pub struct Flattened<'a> {
|
||||||
pub identifier: Vec<usize>,
|
pub identifier: Vec<usize>,
|
||||||
pub item: &'a TreeItem<'a>,
|
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]
|
#[must_use]
|
||||||
pub fn flatten<'a>(opened: &[TreeIdentifierVec], items: &'a [TreeItem<'a>]) -> Vec<Flattened<'a>> {
|
pub fn flatten<'a>(opened: &[TreeIdentifierVec], items: &'a [TreeItem<'a>]) -> Vec<Flattened<'a>> {
|
||||||
internal(opened, items, &[])
|
internal(opened, items, &[])
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ pub type TreeIdentifier<'a> = &'a [usize];
|
|||||||
/// Reference to a [`TreeItem`](crate::TreeItem) in a [`Tree`](crate::Tree)
|
/// Reference to a [`TreeItem`](crate::TreeItem) in a [`Tree`](crate::Tree)
|
||||||
pub type TreeIdentifierVec = Vec<usize>;
|
pub type TreeIdentifierVec = Vec<usize>;
|
||||||
|
|
||||||
/// Split a [`TreeIdentifier`] into its branch and leaf
|
/// Split a [`TreeIdentifier`] into its branch and leaf.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|||||||
+10
-3
@@ -1,5 +1,12 @@
|
|||||||
#![forbid(unsafe_code)]
|
#![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 std::collections::HashSet;
|
||||||
|
|
||||||
use ratatui::buffer::Buffer;
|
use ratatui::buffer::Buffer;
|
||||||
@@ -17,7 +24,7 @@ pub use crate::identifier::{
|
|||||||
get_without_leaf as get_identifier_without_leaf, TreeIdentifier, TreeIdentifierVec,
|
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
|
/// # Example
|
||||||
///
|
///
|
||||||
@@ -198,7 +205,7 @@ impl TreeState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One item inside a [`Tree`]
|
/// One item inside a [`Tree`].
|
||||||
///
|
///
|
||||||
/// Can have zero or more `children`.
|
/// 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
|
/// # Example
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user