Skip to content

Commit

Permalink
ui: Update doc comments (zed-industries#22802)
Browse files Browse the repository at this point in the history
This PR updates some doc comments in the `ui` crate:

- End doc comments with punctuation
- Place doc comments above attributes

Release Notes:

- N/A
  • Loading branch information
maxdeviant authored Jan 7, 2025
1 parent eae88a5 commit d67f2d3
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions crates/ui/src/components/toggle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ use crate::{Color, Icon, IconName, ToggleState};
// TODO: Checkbox, CheckboxWithLabel, Switch, SwitchWithLabel all could be
// restructured to use a ToggleLike, similar to Button/Buttonlike, Label/Labellike

/// Creates a new checkbox
/// Creates a new checkbox.
pub fn checkbox(id: impl Into<ElementId>, toggle_state: ToggleState) -> Checkbox {
Checkbox::new(id, toggle_state)
}

/// Creates a new switch
/// Creates a new switch.
pub fn switch(id: impl Into<ElementId>, toggle_state: ToggleState) -> Switch {
Switch::new(id, toggle_state)
}

/// The visual style of a toggle.
#[derive(Debug, Default, Clone, PartialEq, Eq)]
/// The visual style of a toggle
pub enum ToggleStyle {
/// Toggle has a transparent background
#[default]
Expand Down Expand Up @@ -47,7 +47,7 @@ pub struct Checkbox {
}

impl Checkbox {
/// Creates a new [`Checkbox`]
/// Creates a new [`Checkbox`].
pub fn new(id: impl Into<ElementId>, checked: ToggleState) -> Self {
Self {
id: id.into(),
Expand All @@ -59,13 +59,13 @@ impl Checkbox {
}
}

/// Sets the disabled state of the [`Checkbox`]
/// Sets the disabled state of the [`Checkbox`].
pub fn disabled(mut self, disabled: bool) -> Self {
self.disabled = disabled;
self
}

/// Binds a handler to the [`Checkbox`] that will be called when clicked
/// Binds a handler to the [`Checkbox`] that will be called when clicked.
pub fn on_click(
mut self,
handler: impl Fn(&ToggleState, &mut WindowContext) + 'static,
Expand All @@ -74,19 +74,19 @@ impl Checkbox {
self
}

/// Sets the `fill` setting of the checkbox, indicating whether it should be filled or not
/// Sets the `fill` setting of the checkbox, indicating whether it should be filled.
pub fn fill(mut self) -> Self {
self.filled = true;
self
}

/// Sets the style of the checkbox using the specified [`ToggleStyle`]
/// Sets the style of the checkbox using the specified [`ToggleStyle`].
pub fn style(mut self, style: ToggleStyle) -> Self {
self.style = style;
self
}

/// Match the style of the checkbox to the current elevation using [`ToggleStyle::ElevationBased`]
/// Match the style of the checkbox to the current elevation using [`ToggleStyle::ElevationBased`].
pub fn elevation(mut self, elevation: ElevationIndex) -> Self {
self.style = ToggleStyle::ElevationBased(elevation);
self
Expand Down Expand Up @@ -191,7 +191,7 @@ pub struct CheckboxWithLabel {
}

impl CheckboxWithLabel {
/// Creates a checkbox with an attached label
/// Creates a checkbox with an attached label.
pub fn new(
id: impl Into<ElementId>,
label: Label,
Expand All @@ -208,19 +208,19 @@ impl CheckboxWithLabel {
}
}

/// Sets the style of the checkbox using the specified [`ToggleStyle`]
/// Sets the style of the checkbox using the specified [`ToggleStyle`].
pub fn style(mut self, style: ToggleStyle) -> Self {
self.style = style;
self
}

/// Match the style of the checkbox to the current elevation using [`ToggleStyle::ElevationBased`]
/// Match the style of the checkbox to the current elevation using [`ToggleStyle::ElevationBased`].
pub fn elevation(mut self, elevation: ElevationIndex) -> Self {
self.style = ToggleStyle::ElevationBased(elevation);
self
}

/// Sets the `fill` setting of the checkbox, indicating whether it should be filled or not
/// Sets the `fill` setting of the checkbox, indicating whether it should be filled.
pub fn fill(mut self) -> Self {
self.filled = true;
self
Expand Down Expand Up @@ -265,7 +265,7 @@ pub struct Switch {
}

impl Switch {
/// Creates a new [`Switch`]
/// Creates a new [`Switch`].
pub fn new(id: impl Into<ElementId>, state: ToggleState) -> Self {
Self {
id: id.into(),
Expand All @@ -275,13 +275,13 @@ impl Switch {
}
}

/// Sets the disabled state of the [`Switch`]
/// Sets the disabled state of the [`Switch`].
pub fn disabled(mut self, disabled: bool) -> Self {
self.disabled = disabled;
self
}

/// Binds a handler to the [`Switch`] that will be called when clicked
/// Binds a handler to the [`Switch`] that will be called when clicked.
pub fn on_click(
mut self,
handler: impl Fn(&ToggleState, &mut WindowContext) + 'static,
Expand Down Expand Up @@ -362,8 +362,8 @@ impl RenderOnce for Switch {
}
}

#[derive(IntoElement)]
/// A [`Switch`] that has a [`Label`].
#[derive(IntoElement)]
pub struct SwitchWithLabel {
id: ElementId,
label: Label,
Expand All @@ -372,7 +372,7 @@ pub struct SwitchWithLabel {
}

impl SwitchWithLabel {
/// Creates a switch with an attached label
/// Creates a switch with an attached label.
pub fn new(
id: impl Into<ElementId>,
label: Label,
Expand Down

0 comments on commit d67f2d3

Please sign in to comment.