diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da1ae863..206e4fbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,6 +116,16 @@ jobs: - uses: Swatinem/rust-cache@v2 - run: cargo xtask check + # Check if README.md is up-to-date with the crate's documentation. + check-readme: + name: Check README + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - run: cargo install cargo-rdme + - run: cargo xtask check-readme + # Run cargo rustdoc with the same options that would be used by docs.rs, taking into account the # package.metadata.docs.rs configured in Cargo.toml. https://github.com/dtolnay/cargo-docs-rs lint-docs: diff --git a/README.md b/README.md index 3eeea990..5b09f56f 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ are drawn to the terminal. See the [Widgets] section of the [Ratatui Website] fo The closure passed to the [`Terminal::draw`] method should handle the rendering of a full frame. ```rust -use ratatui::{Frame, widgets::Paragraph}; +use ratatui::{widgets::Paragraph, Frame}; fn run(terminal: &mut ratatui::DefaultTerminal) -> std::io::Result<()> { loop { @@ -209,7 +209,7 @@ use ratatui::{ fn draw(frame: &mut Frame) { use Constraint::{Fill, Length, Min}; - let vertical = Layout::vertical([Length(1), Min(0),Length(1)]); + let vertical = Layout::vertical([Length(1), Min(0), Length(1)]); let [title_area, main_area, status_area] = vertical.areas(frame.area()); let horizontal = Layout::horizontal([Fill(1); 2]); let [left_area, right_area] = horizontal.areas(main_area); @@ -293,7 +293,7 @@ fn draw(frame: &mut Frame) { [Layout]: https://ratatui.rs/how-to/layout/ [Styling Text]: https://ratatui.rs/how-to/render/style-text/ [templates]: https://github.com/ratatui/templates/ -[Examples]: https://github.com/ratatui/ratatui/blob/main/ratatui/examples/README.md +[Examples]: https://github.com/ratatui/ratatui/tree/main/examples/README.md [Report a bug]: https://github.com/ratatui/ratatui/issues/new?labels=bug&projects=&template=bug_report.md [Request a Feature]: https://github.com/ratatui/ratatui/issues/new?labels=enhancement&projects=&template=feature_request.md [Create a Pull Request]: https://github.com/ratatui/ratatui/compare diff --git a/ratatui-core/Cargo.toml b/ratatui-core/Cargo.toml index a1d5c0b9..efc59718 100644 --- a/ratatui-core/Cargo.toml +++ b/ratatui-core/Cargo.toml @@ -5,13 +5,13 @@ description = """ Widget libraries should use this crate. Applications should use the main Ratatui crate. """ version = "0.3.0" +readme = "README.md" authors.workspace = true documentation.workspace = true repository.workspace = true homepage.workspace = true keywords.workspace = true categories.workspace = true -readme.workspace = true license.workspace = true exclude.workspace = true edition.workspace = true diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 64342373..67303b53 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -59,6 +59,10 @@ enum Command { #[command(visible_alias = "c")] Check, + /// Check if README.md is up-to-date + #[command(visible_alias = "cr")] + CheckReadme, + /// Generate code coverage report #[command(visible_alias = "cov")] Coverage, @@ -129,6 +133,7 @@ impl Command { Command::CI => ci(), Command::Build => build(), Command::Check => check(), + Command::CheckReadme => check_readme(), Command::Coverage => coverage(), Command::Lint => lint(), Command::LintClippy => lint_clippy(), @@ -165,6 +170,11 @@ fn check() -> Result<()> { run_cargo(vec!["check", "--all-targets", "--all-features"]) } +/// Run cargo-rdme to check if README.md is up-to-date with the library documentation +fn check_readme() -> Result<()> { + run_cargo(vec!["rdme", "--workspace-project", "ratatui", "--check"]) +} + /// Generate code coverage report fn coverage() -> Result<()> { run_cargo(vec![