From 50ab82f2628528940900950bf4c25b0a9f67d00f Mon Sep 17 00:00:00 2001 From: Enrico Zandomeni Borba Date: Sun, 18 Sep 2022 17:56:48 -1000 Subject: [PATCH] fix docs --- .../experimental_components/input.rs | 4 +-- intuitive/src/lib.rs | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/intuitive/src/components/experimental_components/input.rs b/intuitive/src/components/experimental_components/input.rs index b7db6af..88f8811 100644 --- a/intuitive/src/components/experimental_components/input.rs +++ b/intuitive/src/components/experimental_components/input.rs @@ -63,8 +63,8 @@ use crate::{ /// } /// ``` /// -/// [`VStack`]: struct.VStack.html -/// [`Flex::Block`]: stack/enum.Flex.html#variant.Block +/// [`VStack`]: ../../struct.VStack.html +/// [`Flex::Block`]: ../../stack/enum.Flex.html#variant.Block #[component(Input)] pub fn render(title: Spans, border: Style, on_key: KeyHandler, on_mouse: MouseHandler) { let cursor = use_state(|| 0usize); diff --git a/intuitive/src/lib.rs b/intuitive/src/lib.rs index 55ff86c..a29594c 100644 --- a/intuitive/src/lib.rs +++ b/intuitive/src/lib.rs @@ -162,6 +162,32 @@ pub mod text; /// have only a single child), and therefore the `on_key` handler could have been /// provided to any of the [`Centered`], [`Section`], or [`Text`] components above. /// +/// # Generics +/// When requiring generics, for example when accepting a variable number of children, +/// they can be added into the attribute and then used in the parameters. For example: +/// ```rust +/// # use intuitive::{component, components::{Centered, children::Children, Section, Text}, on_key, state::use_state, render}; +/// # +/// #[component(Root)] +/// pub fn render(title: String, children: Children) { +/// let text = use_state(String::new); +/// +/// let on_key = on_key! { [text] +/// KeyEvent { code: Char(c), .. } => text.mutate(|text| text.push(c)), +/// KeyEvent { code: Char(c), .. } => text.mutate(|text| text.pop()), +/// KeyEvent { code: Esc, .. } => event::quit(), +/// }; +/// +/// render! { +/// Centered() { +/// Section(title) { +/// Text(text: text.get(), on_key) +/// } +/// } +/// } +/// } +/// ``` +/// /// # Generated Component /// The generated component is a structure that implements the [`Component`] trait. It /// also has a an associated function `new() -> component::Any` that is used to create the