Skip to content

Commit

Permalink
feat(doc): add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
meloalright committed Nov 16, 2024
1 parent 4432159 commit 0c286b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ pub enum CSSDirection {
}


/// Create and get a TaitankSafeNode.
///
/// # Examples
///
/// ```
/// let root = taitank_safe::node_create();
/// println!("{:?}", root);
/// ```
pub fn node_create() -> TaitankSafeNode {
TaitankSafeNode {
unique_ptr: ffi::node_create(),
Expand Down Expand Up @@ -130,6 +138,16 @@ pub fn set_justify_content(node: &mut TaitankSafeNode, flex_align: FlexAlign) {
pub fn insert_child(node: &mut TaitankSafeNode, child: &mut TaitankSafeNode, index: i32) {
ffi::insert_child(&mut node.unique_ptr, &mut child.unique_ptr, index);
}

/// Layout the node.
///
/// # Examples
///
/// ```
/// let mut root = taitank_safe::node_create();
/// taitank_safe::set_width(&mut root);
/// taitank_safe::do_layout(&mut root, std::f64::NAN, std::f64::NAN, taitank_safe::Direction::LTR);
/// ```
pub fn do_layout(
node: &mut TaitankSafeNode,
parent_width: f64,
Expand Down
10 changes: 10 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@

/// Layout the node using macro.
///
/// # Examples
///
/// ```
/// let mut root = taitank_safe::node_create();
/// taitank_safe::set_width(&mut root);
/// taitank_safe::layout!(&mut root);
/// ```
#[macro_export]
macro_rules! layout {
($a:expr, $b:expr, $c:expr, $d:expr) => {
Expand Down

0 comments on commit 0c286b3

Please sign in to comment.