Skip to content

Commit

Permalink
chore(editorconfig): set and apply some defaults (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo authored and joshka committed Mar 4, 2024
1 parent 3834374 commit 38c17e0
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 35 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/check-pr.yml
Expand Up @@ -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
10 changes: 5 additions & 5 deletions BREAKING-CHANGES.md
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions CONTRIBUTING.md
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bacon.toml
Expand Up @@ -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",
]

Expand Down
2 changes: 1 addition & 1 deletion examples/vhs/custom_widget.tape
Expand Up @@ -18,4 +18,4 @@ Space
Left
Space
Left
Space
Space
2 changes: 1 addition & 1 deletion examples/vhs/demo2-destroy.tape
Expand Up @@ -15,4 +15,4 @@ Enter
Sleep 2s
Show
Type "d"
Sleep 30s
Sleep 30s
2 changes: 1 addition & 1 deletion examples/vhs/demo2-social.tape
Expand Up @@ -40,4 +40,4 @@ Tab
# Weather
Set TypingSpeed 100ms
Down 40
Sleep 2s
Sleep 2s
2 changes: 1 addition & 1 deletion examples/vhs/demo2.tape
Expand Up @@ -46,4 +46,4 @@ Tab
Screenshot "target/demo2-weather.png"
Set TypingSpeed 100ms
Down 40
Sleep 2s
Sleep 2s
12 changes: 6 additions & 6 deletions src/widgets/barchart.rs
Expand Up @@ -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::*};
Expand Down Expand Up @@ -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.
/// ```
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/barchart/bar.rs
Expand Up @@ -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> {
Expand All @@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/block.rs
Expand Up @@ -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
Expand Down Expand Up @@ -193,7 +193,7 @@ impl<'a> Block<'a> {
/// [spans](crate::text::Span) (`Vec<Span>`).
///
/// 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.
///
Expand Down
8 changes: 4 additions & 4 deletions src/widgets/gauge.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 38c17e0

Please sign in to comment.