From 621226f2e21816263b45ca3be29804559f98b218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Wed, 5 Feb 2025 21:20:55 +0300 Subject: [PATCH] docs(examples): move inline example to examples folder (#1651) --- Cargo.lock | 18 ++++++++++---- examples/README.md | 7 +++++- examples/apps/inline/Cargo.toml | 15 ++++++++++++ examples/apps/inline/README.md | 9 +++++++ .../apps/inline/src/main.rs | 24 +++++++------------ ratatui/Cargo.toml | 5 ---- 6 files changed, 53 insertions(+), 25 deletions(-) create mode 100644 examples/apps/inline/Cargo.toml create mode 100644 examples/apps/inline/README.md rename ratatui/examples/inline.rs => examples/apps/inline/src/main.rs (92%) diff --git a/Cargo.lock b/Cargo.lock index 59463a59..f949c4d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1554,6 +1554,16 @@ version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" +[[package]] +name = "inline" +version = "0.0.0" +dependencies = [ + "color-eyre", + "crossterm", + "rand 0.9.0", + "ratatui", +] + [[package]] name = "input-form" version = "0.0.0" @@ -3738,12 +3748,12 @@ dependencies = [ [[package]] name = "uuid" -version = "1.12.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" +checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0" dependencies = [ "atomic", - "getrandom 0.2.15", + "getrandom 0.3.1", ] [[package]] @@ -3911,7 +3921,7 @@ dependencies = [ "once_cell", "sha2", "thiserror 1.0.69", - "uuid 1.12.1", + "uuid 1.13.1", ] [[package]] diff --git a/examples/README.md b/examples/README.md index e0de58ff..258e9e61 100644 --- a/examples/README.md +++ b/examples/README.md @@ -79,7 +79,8 @@ This example shows how to create a custom widget that can be interacted with the ## Hyperlink demo -Shows how to render hyperlinks in a terminal using [OSC 8](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). [Source](./apps/hyperlink/). +Shows how to render hyperlinks in a terminal using [OSC +8](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). [Source](./apps/hyperlink/). ## Flex demo @@ -93,6 +94,10 @@ This example shows how to create a simple TUI with a text. [Source](./apps/hello This example shows different types of gauges. [Source](./apps/gauge/). +## Inline demo + +Shows how to use the inlined viewport to render in a specific area of the screen. [Source](./apps/inline/). + ## Input form Shows how to render a form with input fields. [Source](./apps/input-form/). diff --git a/examples/apps/inline/Cargo.toml b/examples/apps/inline/Cargo.toml new file mode 100644 index 00000000..880e401a --- /dev/null +++ b/examples/apps/inline/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "inline" +publish = false +license.workspace = true +edition.workspace = true +rust-version.workspace = true + +[dependencies] +color-eyre.workspace = true +crossterm.workspace = true +rand = "0.9.0" +ratatui.workspace = true + +[lints] +workspace = true diff --git a/examples/apps/inline/README.md b/examples/apps/inline/README.md new file mode 100644 index 00000000..cb6f4473 --- /dev/null +++ b/examples/apps/inline/README.md @@ -0,0 +1,9 @@ +# Inline demo + +This example shows how to use the inlined viewport to render in a specific area of the screen. + +To run this demo: + +```shell +cargo run -p inline +``` diff --git a/ratatui/examples/inline.rs b/examples/apps/inline/src/main.rs similarity index 92% rename from ratatui/examples/inline.rs rename to examples/apps/inline/src/main.rs index 59d976c5..59b1e7a2 100644 --- a/ratatui/examples/inline.rs +++ b/examples/apps/inline/src/main.rs @@ -1,18 +1,12 @@ -//! # [Ratatui] Inline 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 how to use the inlined viewport. +/// +/// It shows a list of downloads in progress, with a progress bar for each download. +/// +/// 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::{ collections::{BTreeMap, VecDeque}, sync::mpsc, diff --git a/ratatui/Cargo.toml b/ratatui/Cargo.toml index cc2d1c1a..a6c49ab7 100644 --- a/ratatui/Cargo.toml +++ b/ratatui/Cargo.toml @@ -141,11 +141,6 @@ bench = false name = "main" harness = false -[[example]] -name = "inline" -required-features = ["crossterm"] -doc-scrape-examples = true - [[example]] name = "list-widget" required-features = ["crossterm"]