Replace ignored doc-tests with additional documentation for `Padding`

This commit is contained in:
Héctor Ramón 2021-06-01 19:45:47 +07:00
parent b94cd7a2a8
commit 8a3b71df8b
16 changed files with 32 additions and 75 deletions

View File

@ -1,4 +1,36 @@
/// An amount of space to pad for each side of a box
///
/// You can leverage the `From` trait to build [`Padding`] conveniently:
///
/// ```
/// # use iced_core::Padding;
/// #
/// let padding = Padding::from(20); // 20px on all sides
/// let padding = Padding::from([10, 20]); // top/bottom, left/right
/// let padding = Padding::from([5, 10, 15, 20]); // top, right, bottom, left
/// ```
///
/// Normally, the `padding` method of a widget will ask for an `Into<Padding>`,
/// so you can easily write:
///
/// ```
/// # use iced_core::Padding;
/// #
/// # struct Widget;
/// #
/// impl Widget {
/// # pub fn new() -> Self { Self }
/// #
/// pub fn padding(mut self, padding: impl Into<Padding>) -> Self {
/// // ...
/// self
/// }
/// }
///
/// let widget = Widget::new().padding(20); // 20px on all sides
/// let widget = Widget::new().padding([10, 20]); // top/bottom, left/right
/// let widget = Widget::new().padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
#[derive(Debug, Hash, Copy, Clone)]
pub struct Padding {
/// Top padding

View File

@ -59,11 +59,6 @@ where
}
/// Sets the [`Padding`] of the [`Menu`].
///```ignore
/// Menu::new(/*...*/).padding(20); // 20px on all sides
/// Menu::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Menu::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -91,11 +91,6 @@ where
}
/// Sets the [`Padding`] of the [`Button`].
///```ignore
/// Button::new(/*...*/).padding(20); // 20px on all sides
/// Button::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Button::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -57,11 +57,6 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
}
/// Sets the [`Padding`] of the [`Column`].
///```ignore
/// Column::new(/*...*/).padding(20); // 20px on all sides
/// Column::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Column::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -50,11 +50,6 @@ where
}
/// Sets the [`Padding`] of the [`Container`].
///```ignore
/// Container::new(/*...*/).padding(20); // 20px on all sides
/// Container::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Container::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -46,11 +46,6 @@ where
}
/// Sets the [`Padding`] of the [`TitleBar`].
///```ignore
/// TitleBar::new(/*...*/).padding(20); // 20px on all sides
/// TitleBar::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// TitleBar::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -98,11 +98,6 @@ where
}
/// Sets the [`Padding`] of the [`PickList`].
///```ignore
/// PickList::new(/*...*/).padding(20); // 20px on all sides
/// PickList::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// PickList::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -56,11 +56,6 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> {
}
/// Sets the [`Padding`] of the [`Row`].
///```ignore
/// Row::new(/*...*/).padding(20); // 20px on all sides
/// Row::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Row::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -52,11 +52,6 @@ impl<'a, Message, Renderer: self::Renderer> Scrollable<'a, Message, Renderer> {
}
/// Sets the [`Padding`] of the [`Scrollable`].
///```ignore
/// Scrollable::new(/*...*/).padding(20); // 20px on all sides
/// Scrollable::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Scrollable::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.content = self.content.padding(padding);
self

View File

@ -128,11 +128,6 @@ where
}
/// Sets the [`Padding`] of the [`TextInput`].
///```ignore
/// TextInput::new(/*...*/).padding(20); // 20px on all sides
/// TextInput::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// TextInput::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -78,11 +78,6 @@ impl<'a, Message> Button<'a, Message> {
}
/// Sets the [`Padding`] of the [`Button`].
///```ignore
/// Button::new(/*...*/).padding(20); // 20px on all sides
/// Button::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Button::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -49,11 +49,6 @@ impl<'a, Message> Column<'a, Message> {
}
/// Sets the [`Padding`] of the [`Column`].
///```ignore
/// Column::new(/*...*/).padding(20); // 20px on all sides
/// Column::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Column::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -42,11 +42,6 @@ impl<'a, Message> Container<'a, Message> {
}
/// Sets the [`Padding`] of the [`Container`].
///```ignore
/// Container::new(/*...*/).padding(20); // 20px on all sides
/// Container::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Container::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -49,11 +49,6 @@ impl<'a, Message> Row<'a, Message> {
}
/// Sets the [`Padding`] of the [`Row`].
///```ignore
/// Row::new(/*...*/).padding(20); // 20px on all sides
/// Row::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Row::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self

View File

@ -42,11 +42,6 @@ impl<'a, Message> Scrollable<'a, Message> {
}
/// Sets the [`Padding`] of the [`Scrollable`].
///```ignore
/// Scrollable::new(/*...*/).padding(20); // 20px on all sides
/// Scrollable::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// Scrollable::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.content = self.content.padding(padding);
self

View File

@ -93,11 +93,6 @@ impl<'a, Message> TextInput<'a, Message> {
}
/// Sets the [`Padding`] of the [`TextInput`].
///```ignore
/// TextInput::new(/*...*/).padding(20); // 20px on all sides
/// TextInput::new(/*...*/).padding([10, 20]); // top/bottom, left/right
/// TextInput::new(/*...*/).padding([5, 10, 15, 20]); // top, right, bottom, left
/// ```
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
self.padding = padding.into();
self