From 325f96102a2a798353154430db4c1e9b12e254d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 5 Feb 2025 03:05:52 +0300 Subject: [PATCH] docs(examples): move hello-world example to examples folder (#1647) --- Cargo.lock | 9 ++++++++ examples/README.md | 4 ++++ examples/apps/hello-world/Cargo.toml | 14 ++++++++++++ examples/apps/hello-world/README.md | 9 ++++++++ .../apps/hello-world/src/main.rs | 22 ++++++------------- ratatui/Cargo.toml | 5 ----- 6 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 examples/apps/hello-world/Cargo.toml create mode 100644 examples/apps/hello-world/README.md rename ratatui/examples/hello_world.rs => examples/apps/hello-world/src/main.rs (76%) diff --git a/Cargo.lock b/Cargo.lock index f37011c5..cb4ac30d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1174,6 +1174,15 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hello-world" +version = "0.0.0" +dependencies = [ + "color-eyre", + "crossterm", + "ratatui", +] + [[package]] name = "hermit-abi" version = "0.4.0" diff --git a/examples/README.md b/examples/README.md index 5ef21f7e..e3fe2e33 100644 --- a/examples/README.md +++ b/examples/README.md @@ -65,6 +65,10 @@ Shows how to render a canvas with different shapes. [Source](./apps/canvas/). This example shows the full range of RGB colors in an animation. [Source](./apps/colors-rgb/). +## Hello World demo + +This example shows how to create a simple TUI with a text. [Source](./apps/hello-world/). + ## Input form Shows how to render a form with input fields. [Source](./apps/input-form/). diff --git a/examples/apps/hello-world/Cargo.toml b/examples/apps/hello-world/Cargo.toml new file mode 100644 index 00000000..7fd784cf --- /dev/null +++ b/examples/apps/hello-world/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "hello-world" +publish = false +license.workspace = true +edition.workspace = true +rust-version.workspace = true + +[dependencies] +color-eyre.workspace = true +crossterm.workspace = true +ratatui.workspace = true + +[lints] +workspace = true diff --git a/examples/apps/hello-world/README.md b/examples/apps/hello-world/README.md new file mode 100644 index 00000000..a9a6778c --- /dev/null +++ b/examples/apps/hello-world/README.md @@ -0,0 +1,9 @@ +# Hello World demo + +This example shows how to create a simple TUI with a text. + +To run this demo: + +```shell +cargo run -p hello-world +``` diff --git a/ratatui/examples/hello_world.rs b/examples/apps/hello-world/src/main.rs similarity index 76% rename from ratatui/examples/hello_world.rs rename to examples/apps/hello-world/src/main.rs index 9e814620..7be5d68d 100644 --- a/ratatui/examples/hello_world.rs +++ b/examples/apps/hello-world/src/main.rs @@ -1,18 +1,10 @@ -//! # [Ratatui] Hello World example -//! -//! The latest version of this example is available in the [examples] folder in the repository. -//! -//! Please note that the examples are designed to be run against the `main` branch of the Github -//! repository. This means that you may not be able to compile with the latest release version on -//! crates.io, or the one that you have installed locally. -//! -//! See the [examples readme] for more information on finding examples that match the version of the -//! library you are using. -//! -//! [Ratatui]: https://github.com/ratatui/ratatui -//! [examples]: https://github.com/ratatui/ratatui/blob/main/examples -//! [examples readme]: https://github.com/ratatui/ratatui/blob/main/examples/README.md - +/// A Ratatui example that demonstrates a basic hello world application. +/// +/// This example runs with the Ratatui library code in the branch that you are currently +/// reading. See the [`latest`] branch for the code which works with the most recent Ratatui +/// release. +/// +/// [`latest`]: https://github.com/ratatui/ratatui/tree/latest use std::time::Duration; use color_eyre::{eyre::Context, Result}; diff --git a/ratatui/Cargo.toml b/ratatui/Cargo.toml index 5b5a54d8..707c51f2 100644 --- a/ratatui/Cargo.toml +++ b/ratatui/Cargo.toml @@ -172,11 +172,6 @@ name = "gauge-widget" required-features = ["crossterm"] doc-scrape-examples = true -[[example]] -name = "hello_world" -required-features = ["crossterm"] -doc-scrape-examples = true - [[example]] name = "inline" required-features = ["crossterm"]