From b60194844a0f81a864f00e0637b6a4d131194fc5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 11 May 2023 15:40:57 +0200 Subject: Write missing documentation in `iced_widget` --- widget/src/lazy.rs | 3 +++ widget/src/lazy/helpers.rs | 8 ++++++++ widget/src/lib.rs | 2 +- widget/src/overlay.rs | 1 + widget/src/text.rs | 2 ++ 5 files changed, 15 insertions(+), 1 deletion(-) (limited to 'widget/src') diff --git a/widget/src/lazy.rs b/widget/src/lazy.rs index b08ed8cb..0ad46865 100644 --- a/widget/src/lazy.rs +++ b/widget/src/lazy.rs @@ -26,6 +26,7 @@ use std::cell::RefCell; use std::hash::{Hash, Hasher as H}; use std::rc::Rc; +/// A widget that only rebuilds its contents when necessary. #[allow(missing_debug_implementations)] pub struct Lazy<'a, Message, Renderer, Dependency, View> { dependency: Dependency, @@ -41,6 +42,8 @@ where Dependency: Hash + 'a, View: Into>, { + /// Creates a new [`Lazy`] widget with the given data `Dependency` and a + /// closure that can turn this data into a widget tree. pub fn new( dependency: Dependency, view: impl Fn(&Dependency) -> View + 'a, diff --git a/widget/src/lazy/helpers.rs b/widget/src/lazy/helpers.rs index be60bb78..8ca9cb86 100644 --- a/widget/src/lazy/helpers.rs +++ b/widget/src/lazy/helpers.rs @@ -4,6 +4,8 @@ use crate::lazy::{Lazy, Responsive}; use std::hash::Hash; +/// Creates a new [`Lazy`] widget with the given data `Dependency` and a +/// closure that can turn this data into a widget tree. pub fn lazy<'a, Message, Renderer, Dependency, View>( dependency: Dependency, view: impl Fn(&Dependency) -> View + 'a, @@ -29,6 +31,12 @@ where component::view(component) } +/// Creates a new [`Responsive`] widget with a closure that produces its +/// contents. +/// +/// The `view` closure will be provided with the current [`Size`] of +/// the [`Responsive`] widget and, therefore, can be used to build the +/// contents of the widget in a responsive way. pub fn responsive<'a, Message, Renderer>( f: impl Fn(Size) -> Element<'a, Message, Renderer> + 'a, ) -> Responsive<'a, Message, Renderer> diff --git a/widget/src/lib.rs b/widget/src/lib.rs index 904f62ad..ab1ab95b 100644 --- a/widget/src/lib.rs +++ b/widget/src/lib.rs @@ -4,7 +4,7 @@ )] #![deny( missing_debug_implementations, - //missing_docs, + missing_docs, unused_results, clippy::extra_unused_lifetimes, clippy::from_over_into, diff --git a/widget/src/overlay.rs b/widget/src/overlay.rs index b9a0e3e0..bc0ed744 100644 --- a/widget/src/overlay.rs +++ b/widget/src/overlay.rs @@ -1 +1,2 @@ +//! Display interactive elements on top of other widgets. pub mod menu; diff --git a/widget/src/text.rs b/widget/src/text.rs index 04c31edc..ce4f44bd 100644 --- a/widget/src/text.rs +++ b/widget/src/text.rs @@ -1,4 +1,6 @@ +//! Draw and interact with text. pub use crate::core::widget::text::*; +/// A paragraph. pub type Text<'a, Renderer = crate::Renderer> = crate::core::widget::Text<'a, Renderer>; -- cgit