summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-19 06:10:44 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-09-19 06:10:44 +0200
commit6ad7c7d3080816d37b17f1f6f5af5d8761983fdc (patch)
treebfaa5375c6908c4121db067f6d33cefa4876d8b8 /core/src
parent9773631354aa1af354647fbdbdd8111da2816afb (diff)
downloadiced-6ad7c7d3080816d37b17f1f6f5af5d8761983fdc.tar.gz
iced-6ad7c7d3080816d37b17f1f6f5af5d8761983fdc.tar.bz2
iced-6ad7c7d3080816d37b17f1f6f5af5d8761983fdc.zip
Show `text` doc examples in multiple places
Diffstat (limited to 'core/src')
-rw-r--r--core/src/widget/text.rs46
1 files changed, 44 insertions, 2 deletions
diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs
index d8d6e4c6..8b02f8c2 100644
--- a/core/src/widget/text.rs
+++ b/core/src/widget/text.rs
@@ -1,4 +1,25 @@
-//! Write some text for your users to read.
+//! Text widgets display information through writing.
+//!
+//! # Example
+//! ```no_run
+//! # mod iced { pub mod widget { pub fn text<T>(t: T) -> iced_core::widget::Text<'static, iced_core::Theme, ()> { unimplemented!() } }
+//! # pub use iced_core::color; }
+//! # pub type State = ();
+//! # pub type Element<'a, Message> = iced_core::Element<'a, Message, iced_core::Theme, ()>;
+//! use iced::widget::text;
+//! use iced::color;
+//!
+//! enum Message {
+//! // ...
+//! }
+//!
+//! fn view(state: &State) -> Element<'_, Message> {
+//! text("Hello, this is iced!")
+//! .size(20)
+//! .color(color!(0x0000ff))
+//! .into()
+//! }
+//! ```
use crate::alignment;
use crate::layout;
use crate::mouse;
@@ -13,7 +34,28 @@ use crate::{
pub use text::{LineHeight, Shaping, Wrapping};
-/// A paragraph of text.
+/// A bunch of text.
+///
+/// # Example
+/// ```no_run
+/// # mod iced { pub mod widget { pub fn text<T>(t: T) -> iced_core::widget::Text<'static, iced_core::Theme, ()> { unimplemented!() } }
+/// # pub use iced_core::color; }
+/// # pub type State = ();
+/// # pub type Element<'a, Message> = iced_core::Element<'a, Message, iced_core::Theme, ()>;
+/// use iced::widget::text;
+/// use iced::color;
+///
+/// enum Message {
+/// // ...
+/// }
+///
+/// fn view(state: &State) -> Element<'_, Message> {
+/// text("Hello, this is iced!")
+/// .size(20)
+/// .color(color!(0x0000ff))
+/// .into()
+/// }
+/// ```
#[allow(missing_debug_implementations)]
pub struct Text<'a, Theme, Renderer>
where