Skip to content

Commit

Permalink
fix: make cargo test --doc work with unstable-widget-ref examples (#1117
Browse files Browse the repository at this point in the history
)
  • Loading branch information
joshka committed May 19, 2024
1 parent 4955380 commit fcb5d58
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 147 deletions.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ name = "list"
required-features = ["crossterm"]
doc-scrape-examples = true

[[example]]
name = "minimal"
required-features = ["crossterm"]
# prefer to show the more featureful examples in the docs
doc-scrape-examples = false

[[example]]
name = "modifiers"
required-features = ["crossterm"]
Expand Down
4 changes: 4 additions & 0 deletions src/terminal/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ impl Frame<'_> {
/// # Example
///
/// ```rust
/// # #[cfg(feature = "unstable-widget-ref")] {
/// # use ratatui::{backend::TestBackend, prelude::*, widgets::Block};
/// # let backend = TestBackend::new(5, 5);
/// # let mut terminal = Terminal::new(backend).unwrap();
/// # let mut frame = terminal.get_frame();
/// let block = Block::new();
/// let area = Rect::new(0, 0, 5, 5);
/// frame.render_widget_ref(block, area);
/// # }
/// ```
#[allow(clippy::needless_pass_by_value)]
#[stability::unstable(feature = "widget-ref")]
Expand Down Expand Up @@ -138,6 +140,7 @@ impl Frame<'_> {
/// # Example
///
/// ```rust
/// # #[cfg(feature = "unstable-widget-ref")] {
/// # use ratatui::{backend::TestBackend, prelude::*, widgets::*};
/// # let backend = TestBackend::new(5, 5);
/// # let mut terminal = Terminal::new(backend).unwrap();
Expand All @@ -146,6 +149,7 @@ impl Frame<'_> {
/// let list = List::new(vec![ListItem::new("Item 1"), ListItem::new("Item 2")]);
/// let area = Rect::new(0, 0, 5, 5);
/// frame.render_stateful_widget_ref(list, area, &mut state);
/// # }
/// ```
#[allow(clippy::needless_pass_by_value)]
#[stability::unstable(feature = "widget-ref")]
Expand Down
Loading

0 comments on commit fcb5d58

Please sign in to comment.