More docs review.

This commit is contained in:
Well 2024-02-12 19:00:28 -03:00
parent 78f8a61e79
commit e1f6802567
16 changed files with 38 additions and 32 deletions

View File

@ -5,7 +5,8 @@
- Review badges.
* Review docs.
- Do a full read, look for typos or failed links.
- Last reviewed `zero_ui::focus`.
- Last reviewing `zero_ui::font`.
- Last reviewed `FontChangedArgs`
# Publish

View File

@ -250,7 +250,7 @@ impl Command {
/// A handle indicates that command handlers are present in the current app, the `enabled` flag
/// indicates the handler is ready to fulfill command requests.
///
/// If the command is scoped on a window or widget it it is added to the command event subscribers.
/// If the command is scoped on a window or widget if it is added to the command event subscribers.
pub fn subscribe(&self, enabled: bool) -> CommandHandle {
let mut evs = EVENTS_SV.write();
self.local.write().subscribe(&mut evs, *self, enabled, None)

View File

@ -40,7 +40,7 @@ pub trait WidgetHandler<A: Clone + 'static>: Any + Send {
/// Box the handler.
///
/// The type `Box<dyn WidgetHandler<A>>` implements `WidgetHandler<A>` and just returns it-self
/// The type `Box<dyn WidgetHandler<A>>` implements `WidgetHandler<A>` and just returns itself
/// in this method, avoiding double boxing.
fn boxed(self) -> Box<dyn WidgetHandler<A>>
where
@ -615,7 +615,7 @@ pub trait AppHandler<A: Clone + 'static>: Any + Send {
/// Boxes the handler.
///
/// The type `Box<dyn AppHandler<A>>` implements `AppHandler<A>` and just returns it-self
/// The type `Box<dyn AppHandler<A>>` implements `AppHandler<A>` and just returns itself
/// in this method, avoiding double boxing.
fn boxed(self) -> Box<dyn AppHandler<A>>
where

View File

@ -1875,7 +1875,7 @@ impl WidgetBuilder {
/// affect the properties are cloned or moved into the new builder.
///
/// Note that properties can depend on others in the widget contextually, this is not preserved on split-off.
/// The canonical usage of split-off is the `style` property, that dynamically (re)builds widgets and is it-self a variable
/// The canonical usage of split-off is the `style` property, that dynamically (re)builds widgets and is itself a variable
/// that can be affected by `when` blocks to a limited extent.
pub fn split_off(&mut self, properties: impl IntoIterator<Item = PropertyId>, out: &mut WidgetBuilder) {
self.split_off_impl(properties.into_iter().collect(), out)

View File

@ -149,7 +149,7 @@ impl<U: UiNode> ArcNode<U> {
self.take_when(true)
}
/// Calls `f` in the context of the node, it it can be locked and is a full widget.
/// Calls `f` in the context of the node, if it can be locked and is a full widget.
pub fn try_context<R>(&self, update_mode: WidgetUpdateMode, f: impl FnOnce() -> R) -> Option<R> {
self.0.item.try_lock()?.with_context(update_mode, f)
}

View File

@ -71,8 +71,8 @@ impl ColorPalettes {
}
/// Load the table, if present in the font.
pub fn load(ft: &font_kit::font::Font) -> std::io::Result<Self> {
let table = match ft.load_font_table(CPAL) {
pub fn load(font_kit_font: &font_kit::font::Font) -> std::io::Result<Self> {
let table = match font_kit_font.load_font_table(CPAL) {
Some(t) => t,
None => return Ok(Self::empty()),
};
@ -166,7 +166,7 @@ impl ColorPalettes {
self.num_palettes == 0
}
/// Gets the requested palette or the first it it is not found.
/// Gets the requested palette or the first if it is not found.
pub fn palette(&self, p: impl Into<FontColorPalette>) -> Option<ColorPalette> {
let i = self.palette_i(p.into());
self.palette_get(i.unwrap_or(0))
@ -264,8 +264,8 @@ impl ColorGlyphs {
}
/// Load the table, if present in the font.
pub fn load(ft: &font_kit::font::Font) -> std::io::Result<Self> {
let table = match ft.load_font_table(COLR) {
pub fn load(font_kit_font: &font_kit::font::Font) -> std::io::Result<Self> {
let table = match font_kit_font.load_font_table(COLR) {
Some(t) => t,
None => return Ok(Self::empty()),
};
@ -343,7 +343,7 @@ impl ColorGlyphs {
/// to the front (last item). Paired with each glyph is an index in the font's [`ColorPalette::colors`] or
/// `None` if the base text color must be used.
///
/// Yields the `base_glyph` with `None` color if it the font does not provide colored replacements for it.
/// Yields the `base_glyph` with no palette color if the font does not provide colored replacements for it.
pub fn glyph(&self, base_glyph: GlyphIndex) -> Option<ColorGlyph> {
match self.base_glyph_records.binary_search_by_key(&(base_glyph as u16), |e| e.glyph_id) {
Ok(i) => {

View File

@ -780,12 +780,12 @@ impl FONTS {
self.find(family, FontStyle::Normal, FontWeight::NORMAL, FontStretch::NORMAL, lang)
}
/// Find a single font face with italic italic style and normal weight and stretch.
/// Find a single font face with italic style, normal weight and stretch.
pub fn italic(&self, family: &FontName, lang: &Lang) -> ResponseVar<Option<FontFace>> {
self.find(family, FontStyle::Italic, FontWeight::NORMAL, FontStretch::NORMAL, lang)
}
/// Find a single font face with bold weight and normal style and stretch.
/// Find a single font face with bold weight, normal style and stretch.
pub fn bold(&self, family: &FontName, lang: &Lang) -> ResponseVar<Option<FontFace>> {
self.find(family, FontStyle::Normal, FontWeight::BOLD, FontStretch::NORMAL, lang)
}
@ -2390,8 +2390,6 @@ enum FontSource {
}
/// Custom font builder.
///
/// A custom font has a name and a source,
#[derive(Debug, Clone)]
pub struct CustomFont {
name: FontName,
@ -2406,6 +2404,8 @@ impl CustomFont {
/// If the file is a collection of fonts, `font_index` determines which, otherwise just pass `0`.
///
/// The font is loaded in [`FONTS.register`].
///
/// [`FONTS.register`]: FONTS::register
pub fn from_file<N: Into<FontName>, P: Into<PathBuf>>(name: N, path: P, font_index: u32) -> Self {
CustomFont {
name: name.into(),
@ -2421,6 +2421,8 @@ impl CustomFont {
/// If the font data is a collection of fonts, `font_index` determines which, otherwise just pass `0`.
///
/// The font is loaded in [`FONTS.register`].
///
/// [`FONTS.register`]: FONTS::register
pub fn from_bytes<N: Into<FontName>>(name: N, data: FontDataRef, font_index: u32) -> Self {
CustomFont {
name: name.into(),
@ -2434,6 +2436,8 @@ impl CustomFont {
/// A custom font that maps to another font.
///
/// The font is loaded in [`FONTS.register`].
///
/// [`FONTS.register`]: FONTS::register
pub fn from_other<N: Into<FontName>, O: Into<FontName>>(name: N, other_font: O) -> Self {
CustomFont {
name: name.into(),
@ -3120,7 +3124,7 @@ impl fmt::Debug for WhiteSpace {
}
/// Defines an insert offset in a shaped text.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, serde::Serialize, serde::Deserialize)]
pub struct CaretIndex {
/// Char byte offset in the full text.
///
@ -3128,10 +3132,11 @@ pub struct CaretIndex {
pub index: usize,
/// Line index in the shaped text.
///
/// Note that this counts wrap lines, this value is used to disambiguate
/// between the *end* of a wrap and the *start* of the next, the text
/// it-self does not have any line break but visually the user interacts
/// with two lines.
/// This value is only used to disambiguate between the *end* of a wrap and
/// the *start* of the next, the text itself does not have any line
/// break but visually the user interacts with two lines. Note that this
/// counts wrap lines, and that this value is not required to define a valid
/// CaretIndex.
///
/// This index can be computed using the [`ShapedText::snap_caret_line`].
pub line: usize,

View File

@ -29,8 +29,8 @@ impl LigatureCaretList {
}
}
pub fn load(ft: &font_kit::font::Font) -> std::io::Result<Self> {
let table = match ft.load_font_table(GDEF) {
pub fn load(font_kit_font: &font_kit::font::Font) -> std::io::Result<Self> {
let table = match font_kit_font.load_font_table(GDEF) {
Some(d) => d,
None => return Ok(Self::empty()),
};

View File

@ -1967,10 +1967,10 @@ impl FocusInfoData {
}
/// Builder for [`FocusInfo`] accessible in a [`WidgetInfoBuilder`].
///
///
/// There are multiple focusable metadata that can be set on a widget. These rules define how the focusable
/// state of an widget is derived from the focusable metadata.
///
///
/// ### Rules
///
/// The widget is not focusable nor a focus scope if it set [`focusable`](Self::focusable) to `false`.

View File

@ -242,7 +242,7 @@ impl WindowIcon {
/// the closure runs in a headless window context, it must return a node to be rendered as an icon.
///
/// The icon node is deinited and dropped after the first render, you can enable [`image::render_retain`] on it
/// to cause the icon to re-render when the node it-self updates. Note that just because you can update the icon
/// to cause the icon to re-render when the node itself updates. Note that just because you can update the icon
/// does not mean that animating it is a good idea.
///
/// [`image::render_retain`]: fn@zero_ui_ext_image::render_retain

View File

@ -716,7 +716,7 @@ pub trait WeakVar<T: VarValue>: AnyWeakVar + Clone {
/// A value-to-var conversion that consumes the value.
///
/// Every [`Var<T>`] implements this to convert to it-self, every [`VarValue`] implements this to
/// Every [`Var<T>`] implements this to convert to itself, every [`VarValue`] implements this to
/// convert to an [`LocalVar<T>`].
///
/// This trait is used by most properties, it allows then to accept literal values, variables and context variables

View File

@ -229,7 +229,7 @@ pub fn img_align(child: impl UiNode, fit: impl IntoVar<Align>) -> impl UiNode {
/// Sets a [`Point`] that is an offset applied to all inner images within each image widget area.
///
/// Relative values are calculated from the widget final size. Note that this is different the applying the
/// `offset` property on the widget it-self, the widget is not moved just the image within the widget area.
/// `offset` property on the widget itself, the widget is not moved just the image within the widget area.
///
/// This property sets the [`IMAGE_OFFSET_VAR`]. By default no offset is applied.
///

View File

@ -62,7 +62,7 @@ impl Popup {
impl_style_fn!(Popup);
context_var! {
/// If popup will close when it it is no longer contains the focused widget.
/// If popup will close when it no longer contains the focused widget.
///
/// Is `true` by default.
pub static CLOSE_ON_FOCUS_LEAVE_VAR: bool = true;

View File

@ -48,7 +48,7 @@ impl Scrollbar {
/// Thumb widget.
///
/// Recommended widget is [`Thumb!`], but can be any widget that implements
/// thumb behavior and tags it-self in the frame.
/// thumb behavior and tags itself in the frame.
///
/// [`Thumb!`]: struct@super::Thumb
#[property(CHILD, capture, default(super::Thumb!()), widget_impl(Scrollbar))]

View File

@ -101,7 +101,7 @@ pub enum InlineMode {
Allow,
/// Widget always does inline.
///
/// If the parent layout does not setup an inline layout environment the widget it-self will. This
/// If the parent layout does not setup an inline layout environment the widget itself will. This
/// can be used to force the inline visual, such as background clipping or any other special visual
/// that is only enabled when the widget is inlined.
///

View File

@ -425,7 +425,7 @@
//! ```
//!
//! In the example above the container widget sets an exact size using `layout::size` with exact units, the
//! button widget sets a relative size using percentage units and positions it-self in the container using `layout::align`.
//! button widget sets a relative size using percentage units and positions itself in the container using `layout::align`.
//! All the layout properties are stand-alone, in the example only the text widget implements layout directly. Layout
//! properties modify the layout context by setting constraints and defining units, this context is available for all
//! properties that need it during layout, see the [`layout`] module documentation for more details.