📝 Ejemplos de documentación usando prelude

This commit is contained in:
Manuel Cillero 2026-10-13 00:12:13 +02:00
parent d3a9be7550
commit 79655932d0
5 changed files with 18 additions and 26 deletions

View file

@ -10,10 +10,9 @@ use crate::prelude::*;
/// sería necesario llamar a [`Column::new()`] de forma explícita.
///
/// ```rust
/// use pagetop::locale::Lc;
/// use pagetop::base::component::table::Column;
/// use pagetop::prelude::*;
///
/// let column: Column = Lc::n("User").into();
/// let column: table::Column = Lc::n("User").into();
/// assert_eq!(column.label().get(), Some("User".to_string()));
/// assert!(column.sort().is_none());
/// ```

View file

@ -25,8 +25,7 @@ impl SortDir {
/// reconocido) se interpreta como [`Asc`](Self::Asc).
///
/// ```rust
/// use pagetop::html::SortDir;
///
/// # use pagetop::prelude::*;
/// assert_eq!(SortDir::from_query(Some("desc")), SortDir::Desc);
/// assert_eq!(SortDir::from_query(Some("asc")), SortDir::Asc);
/// assert_eq!(SortDir::from_query(Some("")), SortDir::Asc);
@ -44,8 +43,7 @@ impl SortDir {
/// (`"asc"`/`"desc"`).
///
/// ```rust
/// use pagetop::html::SortDir;
///
/// # use pagetop::prelude::*;
/// assert_eq!(SortDir::Asc.as_str(), "asc");
/// assert_eq!(SortDir::Desc.as_str(), "desc");
/// ```
@ -60,8 +58,7 @@ impl SortDir {
/// Devuelve la dirección contraria a esta.
///
/// ```rust
/// use pagetop::html::SortDir;
///
/// # use pagetop::prelude::*;
/// assert_eq!(SortDir::Asc.toggled(), SortDir::Desc);
/// assert_eq!(SortDir::Desc.toggled(), SortDir::Asc);
/// ```
@ -81,8 +78,7 @@ impl SortDir {
/// [`Asc`](Self::Asc), sea cual sea la dirección vigente del listado en conjunto.
///
/// ```rust
/// use pagetop::html::SortDir;
///
/// # use pagetop::prelude::*;
/// // Otro campo determina el orden vigente: el próximo clic aquí empieza en ascendente.
/// assert_eq!(SortDir::next_for(None), SortDir::Asc);
///
@ -104,8 +100,7 @@ impl SortDir {
/// equivalente `alter_param()`, sin tener que escribir `.as_str()` a mano.
///
/// ```rust
/// use pagetop::html::SortDir;
///
/// # use pagetop::prelude::*;
/// assert_eq!(SortDir::Asc.as_ref(), "asc");
/// assert_eq!(SortDir::Desc.as_ref(), "desc");
/// ```
@ -120,8 +115,7 @@ impl AsRef<str> for SortDir {
/// escribir `as_str().to_owned()` a mano.
///
/// ```rust
/// use pagetop::html::SortDir;
///
/// # use pagetop::prelude::*;
/// assert_eq!(String::from(SortDir::Asc), "asc");
/// assert_eq!(String::from(SortDir::Desc), "desc");
/// ```

View file

@ -59,7 +59,7 @@ pub enum NormalizeAsciiError {
/// # Ejemplo
///
/// ```rust
/// # use pagetop::util;
/// # use pagetop::prelude::*;
/// assert_eq!(util::non_blank(" hello "), Some("hello"));
/// assert_eq!(util::non_blank(" "), None);
/// assert_eq!(util::non_blank(""), None);
@ -94,7 +94,7 @@ pub fn non_blank(s: &str) -> Option<&str> {
/// # Ejemplo
///
/// ```rust
/// # use pagetop::util;
/// # use pagetop::prelude::*;
/// assert_eq!(
/// util::normalize_ascii_non_blank(" Foo\tBAR CLi\r\n").unwrap().as_ref(),
/// "foo bar cli"
@ -185,7 +185,7 @@ pub fn normalize_ascii_non_blank(input: &str) -> Result<Cow<'_, str>, NormalizeA
/// # Ejemplo
///
/// ```rust
/// # use pagetop::util;
/// # use pagetop::prelude::*;
/// assert_eq!(
/// util::normalize_ascii(" Foo\tBAR CLi\r\n").unwrap().as_ref(),
/// "foo bar cli"
@ -219,7 +219,7 @@ pub fn normalize_ascii(input: &str) -> Option<Cow<'_, str>> {
/// # Ejemplo
///
/// ```rust
/// # use pagetop::util;
/// # use pagetop::prelude::*;
/// assert_eq!(util::normalize_property(" Flex-Basis "), Some("flex-basis".to_string()));
/// assert_eq!(util::normalize_property(" "), None);
/// ```
@ -241,7 +241,7 @@ pub fn normalize_property(property: impl AsRef<str>) -> Option<String> {
/// # Ejemplo
///
/// ```rust
/// # use pagetop::util;
/// # use pagetop::prelude::*;
/// assert_eq!(util::normalize_token(" My Id "), Some("my_id".to_string()));
/// assert_eq!(util::normalize_token("AÑO\tNuevo"), Some("año_nuevo".to_string()));
/// assert_eq!(util::normalize_token("a b"), Some("a___b".to_string()));
@ -270,7 +270,7 @@ pub fn normalize_token(s: impl AsRef<str>) -> Option<String> {
/// # Ejemplo
///
/// ```rust
/// # use pagetop::util;
/// # use pagetop::prelude::*;
/// assert!(util::url_looks_external("https://example.com"));
/// assert!(util::url_looks_external("mailto:info@example.com"));
/// assert!(util::url_looks_external("HTTPS://EXAMPLE.COM"));