Skip to content

Commit b91fa27

Browse files
committed
📝 Move caveats to crate docs
1 parent 1696756 commit b91fa27

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

crates/terminal-colorsaurus/doc/caveats.md

-7
This file was deleted.

crates/terminal-colorsaurus/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
//! `terminal-colorsaurus` works with most modern terminals and has been [tested extensively](`terminal_survey`).
2020
//! It's also really good at [detecting](`feature_detection`) when querying for the terminal's colors is not supported.
2121
//!
22+
//! ## Caveats
23+
//! Extra care needs to be taken on Unix if your program might share
24+
//! the terminal with another program. This might be the case
25+
//! if you expect your output to be used with a pager e.g. `your_program` | `less`.
26+
//! In that case, a race condition exists because the pager will also set the terminal to raw mode.
27+
//! The `pager` example shows a heuristic to deal with this issue.
28+
//!
2229
//! ## Example 1: Test If the Terminal Uses a Dark Background
2330
//! ```no_run
2431
//! use terminal_colorsaurus::{color_scheme, ColorScheme};
@@ -171,7 +178,6 @@ macro_rules! impl_query_fn {
171178

172179
impl_query_fn! {
173180
/// Detects if the terminal is dark or light.
174-
#[doc = include_str!("../doc/caveats.md")]
175181
#[doc(alias = "theme")]
176182
pub fn color_scheme() -> Result<ColorScheme>;
177183

@@ -182,7 +188,6 @@ impl_query_fn! {
182188

183189
impl_query_fn! {
184190
/// Queries the terminal for it's color scheme (foreground and background color).
185-
#[doc = include_str!("../doc/caveats.md")]
186191
pub fn color_palette() -> Result<ColorPalette>;
187192

188193
pub fn color_palette_with_options(options: QueryOptions) -> Result<ColorPalette> {
@@ -193,7 +198,6 @@ impl_query_fn! {
193198
impl_query_fn! {
194199
/// Queries the terminal for it's foreground color. \
195200
/// If you also need the background color it is more efficient to use [`color_palette`] instead.
196-
#[doc = include_str!("../doc/caveats.md")]
197201
#[doc(alias = "fg")]
198202
pub fn foreground_color() -> Result<Color>;
199203

@@ -205,7 +209,6 @@ impl_query_fn! {
205209
impl_query_fn! {
206210
/// Queries the terminal for it's background color. \
207211
/// If you also need the foreground color it is more efficient to use [`color_palette`] instead.
208-
#[doc = include_str!("../doc/caveats.md")]
209212
#[doc(alias = "fg")]
210213
pub fn background_color() -> Result<Color>;
211214

0 commit comments

Comments
 (0)