From 38c17e091cf3f4de2d196ecdd6a40129019eafc4 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Tue, 27 Feb 2024 12:39:37 +0100 Subject: [PATCH] chore(editorconfig): set and apply some defaults (#974) --- .editorconfig | 6 ++++++ .github/workflows/check-pr.yml | 1 - BREAKING-CHANGES.md | 10 +++++----- CONTRIBUTING.md | 18 +++++++++--------- bacon.toml | 2 +- examples/vhs/custom_widget.tape | 2 +- examples/vhs/demo2-destroy.tape | 2 +- examples/vhs/demo2-social.tape | 2 +- examples/vhs/demo2.tape | 2 +- src/widgets/barchart.rs | 12 ++++++------ src/widgets/barchart/bar.rs | 6 +++--- src/widgets/block.rs | 4 ++-- src/widgets/gauge.rs | 8 ++++---- 13 files changed, 40 insertions(+), 35 deletions(-) diff --git a/.editorconfig b/.editorconfig index be8a539a..3651545a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,6 +2,12 @@ root = true +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + [*.rs] indent_style = space indent_size = 4 diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index 76edb9b8..66aa7ef0 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -84,4 +84,3 @@ jobs: echo "Pull request is labeled as 'do not merge'" echo "This workflow fails so that the pull request cannot be merged" exit 1 - diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md index ae191e48..fd6569be 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -53,15 +53,15 @@ This is a quick summary of the sections below: [#881]: https://github.com/ratatui-org/ratatui/pull/881 -Previously, constraints would stretch to fill all available space, violating constraints if +Previously, constraints would stretch to fill all available space, violating constraints if necessary. -With v0.26.0, `Flex` modes are introduced and the default is `Flex::Start`, which will align -areas associated with constraints to be beginning of the area. With v0.26.0, additionally, -`Min` constraints grow to fill excess space. These changes will allow users to build layouts +With v0.26.0, `Flex` modes are introduced and the default is `Flex::Start`, which will align +areas associated with constraints to be beginning of the area. With v0.26.0, additionally, +`Min` constraints grow to fill excess space. These changes will allow users to build layouts more easily. -With v0.26.0, users will most likely not need to change what constraints they use to create +With v0.26.0, users will most likely not need to change what constraints they use to create existing layouts with `Flex::Start`. However, to get old behavior, use `Flex::Legacy`. ```diff diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index da631072..715685fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -112,7 +112,8 @@ exist to show coverage directly in your editor. E.g.: ### Documentation -Here are some guidelines for writing documentation in Ratatui. +Here are some guidelines for writing documentation in Ratatui. + Every public API **must** be documented. Keep in mind that Ratatui tends to attract beginner Rust users that may not be familiar with Rust @@ -125,10 +126,9 @@ the concepts pointing to the various methods. Focus on interaction with various enough information that helps understand why you might want something. Examples should help users understand a particular usage, not test a feature. They should be as -simple as possible. -Prefer hiding imports and using wildcards to keep things concise. Some imports may still be shown -to demonstrate a particular non-obvious import (e.g. `Stylize` trait to use style methods). -Speaking of `Stylize`, you should use it over the more verbose style setters: +simple as possible. Prefer hiding imports and using wildcards to keep things concise. Some imports +may still be shown to demonstrate a particular non-obvious import (e.g. `Stylize` trait to use style +methods). Speaking of `Stylize`, you should use it over the more verbose style setters: ```rust let style = Style::new().red().bold(); @@ -138,7 +138,7 @@ let style = Style::default().fg(Color::Red).add_modifier(Modifiers::BOLD); #### Format -- First line is summary, second is blank, third onward is more detail +- First line is summary, second is blank, third onward is more detail ```rust /// Summary @@ -148,10 +148,10 @@ let style = Style::default().fg(Color::Red).add_modifier(Modifiers::BOLD); fn foo() {} ``` -- Max line length is 100 characters +- Max line length is 100 characters See [vscode rewrap extension](https://marketplace.visualstudio.com/items?itemName=stkb.rewrap) -- Doc comments are above macros +- Doc comments are above macros i.e. ```rust @@ -160,7 +160,7 @@ i.e. struct Foo {} ``` -- Code items should be between backticks +- Code items should be between backticks i.e. ``[`Block`]``, **NOT** ``[Block]`` ### Deprecation notice diff --git a/bacon.toml b/bacon.toml index d435f407..5bfaaea9 100644 --- a/bacon.toml +++ b/bacon.toml @@ -84,7 +84,7 @@ on_success = "job:doc" # so that we don't open the browser at each change command = [ "cargo", "llvm-cov", "--lcov", "--output-path", "target/lcov.info", - "--all-features", + "--all-features", "--color", "always", ] diff --git a/examples/vhs/custom_widget.tape b/examples/vhs/custom_widget.tape index 8cf422a6..61aeb1b0 100644 --- a/examples/vhs/custom_widget.tape +++ b/examples/vhs/custom_widget.tape @@ -18,4 +18,4 @@ Space Left Space Left -Space \ No newline at end of file +Space diff --git a/examples/vhs/demo2-destroy.tape b/examples/vhs/demo2-destroy.tape index e017288e..77e859c0 100644 --- a/examples/vhs/demo2-destroy.tape +++ b/examples/vhs/demo2-destroy.tape @@ -15,4 +15,4 @@ Enter Sleep 2s Show Type "d" -Sleep 30s \ No newline at end of file +Sleep 30s diff --git a/examples/vhs/demo2-social.tape b/examples/vhs/demo2-social.tape index 58a4a122..186b4a6d 100644 --- a/examples/vhs/demo2-social.tape +++ b/examples/vhs/demo2-social.tape @@ -40,4 +40,4 @@ Tab # Weather Set TypingSpeed 100ms Down 40 -Sleep 2s \ No newline at end of file +Sleep 2s diff --git a/examples/vhs/demo2.tape b/examples/vhs/demo2.tape index e0a80494..05739cf7 100644 --- a/examples/vhs/demo2.tape +++ b/examples/vhs/demo2.tape @@ -46,4 +46,4 @@ Tab Screenshot "target/demo2-weather.png" Set TypingSpeed 100ms Down 40 -Sleep 2s \ No newline at end of file +Sleep 2s diff --git a/src/widgets/barchart.rs b/src/widgets/barchart.rs index acdc5915..f64a61d1 100644 --- a/src/widgets/barchart.rs +++ b/src/widgets/barchart.rs @@ -38,8 +38,8 @@ pub use bar_group::BarGroup; /// /// # Examples /// -/// The following example creates a `BarChart` with two groups of bars. -/// The first group is added by an array slice (`&[(&str, u64)]`). +/// The following example creates a `BarChart` with two groups of bars. +/// The first group is added by an array slice (`&[(&str, u64)]`). /// The second group is added by a [`BarGroup`] instance. /// ``` /// use ratatui::{prelude::*, widgets::*}; @@ -109,7 +109,7 @@ impl<'a> BarChart<'a> { /// /// # Examples /// - /// The following example creates a BarChart with two groups of bars. + /// The following example creates a BarChart with two groups of bars. /// The first group is added by an array slice (`&[(&str, u64)]`). /// The second group is added by a [`BarGroup`] instance. /// ``` @@ -186,17 +186,17 @@ impl<'a> BarChart<'a> { /// For [`Horizontal`](crate::layout::Direction::Horizontal) bars this becomes the height of /// the bar. /// - /// If not set, this defaults to `1`. + /// If not set, this defaults to `1`. /// The bar label also uses this value as its width. #[must_use = "method moves the value of self and returns the modified value"] - pub fn bar_width(mut self, width: u16) -> BarChart<'a> { + pub const fn bar_width(mut self, width: u16) -> BarChart<'a> { self.bar_width = width; self } /// Set the gap between each bar. /// - /// If not set, this defaults to `1`. + /// If not set, this defaults to `1`. /// The bar label will never be larger than the bar itself, even if the gap is sufficient. /// /// # Example diff --git a/src/widgets/barchart/bar.rs b/src/widgets/barchart/bar.rs index d355d9a5..70a5ee93 100644 --- a/src/widgets/barchart/bar.rs +++ b/src/widgets/barchart/bar.rs @@ -47,7 +47,7 @@ impl<'a> Bar<'a> { /// /// # See also /// - /// [`Bar::value_style`] to style the value. + /// [`Bar::value_style`] to style the value. /// [`Bar::text_value`] to set the displayed value. #[must_use = "method moves the value of self and returns the modified value"] pub const fn value(mut self, value: u64) -> Bar<'a> { @@ -58,9 +58,9 @@ impl<'a> Bar<'a> { /// Set the label of the bar. /// /// For [`Vertical`](crate::layout::Direction::Vertical) bars, - /// display the label **under** the bar. + /// display the label **under** the bar. /// For [`Horizontal`](crate::layout::Direction::Horizontal) bars, - /// display the label **in** the bar. + /// display the label **in** the bar. /// See [`BarChart::direction`](crate::widgets::BarChart::direction) to set the direction. #[must_use = "method moves the value of self and returns the modified value"] pub fn label(mut self, label: Line<'a>) -> Bar<'a> { diff --git a/src/widgets/block.rs b/src/widgets/block.rs index 66d86ee6..918fe9f2 100644 --- a/src/widgets/block.rs +++ b/src/widgets/block.rs @@ -27,7 +27,7 @@ pub use title::{Position, Title}; /// both centered and non-centered titles are rendered, the centered space is calculated based on /// the full width of the block, rather than the leftover width. /// -/// Titles are not rendered in the corners of the block unless there is no border on that edge. +/// Titles are not rendered in the corners of the block unless there is no border on that edge. /// If the block is too small and multiple titles overlap, the border may get cut off at a corner. /// /// ```plain @@ -193,7 +193,7 @@ impl<'a> Block<'a> { /// [spans](crate::text::Span) (`Vec`). /// /// By default, the titles will avoid being rendered in the corners of the block but will align - /// against the left or right edge of the block if there is no border on that edge. + /// against the left or right edge of the block if there is no border on that edge. /// The following demonstrates this behavior, notice the second title is one character off to /// the left. /// diff --git a/src/widgets/gauge.rs b/src/widgets/gauge.rs index 8f947ec9..a3794463 100644 --- a/src/widgets/gauge.rs +++ b/src/widgets/gauge.rs @@ -4,9 +4,9 @@ use crate::{prelude::*, widgets::Block}; /// /// A `Gauge` renders a bar filled according to the value given to [`Gauge::percent`] or /// [`Gauge::ratio`]. The bar width and height are defined by the [`Rect`] it is -/// [rendered](Widget::render) in. +/// [rendered](Widget::render) in. /// The associated label is always centered horizontally and vertically. If not set with -/// [`Gauge::label`], the label is the percentage of the bar filled. +/// [`Gauge::label`], the label is the percentage of the bar filled. /// You might want to have a higher precision bar using [`Gauge::use_unicode`]. /// /// This can be useful to indicate the progression of a task, like a download. @@ -236,9 +236,9 @@ fn get_unicode_block<'a>(frac: f64) -> &'a str { /// /// A `LineGauge` renders a thin line filled according to the value given to [`LineGauge::ratio`]. /// Unlike [`Gauge`], only the width can be defined by the [rendering](Widget::render) [`Rect`]. -/// The height is always 1. +/// The height is always 1. /// The associated label is always left-aligned. If not set with [`LineGauge::label`], the label -/// is the percentage of the bar filled. +/// is the percentage of the bar filled. /// You can also set the symbols used to draw the bar with [`LineGauge::line_set`]. /// /// This can be useful to indicate the progression of a task, like a download.