From 5717f8aaaae34cb66cdbfc31f4982c93816ee5a3 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Fri, 28 Aug 2026 22:49:39 +0700 Subject: [PATCH] fix(ci): gate cache & storage crate doctests behind their features Same E0432 class as mytheclipse-event: the crate-root doctests referenced feature-gated types that are absent in reduced-feature test builds flagged by the CI matrix. - mytheclipse-cache: example used MemoryCache (l1-memory) plus MultiLayerCache/CacheAside (cache-aside); the l1-moka and l2-redis builds (which don't enable cache-aside) failed the doctest. Gated the body behind all(l1-memory, cache-aside) with a no-op fallback. - mytheclipse-storage: example used LocalFileStorage (local feature); the gcs and s3 builds failed the doctest. Gated the body behind the local feature with a no-op fallback. Examples remain compile-checked & runnable under default features. --- crates/mytheclipse-cache/src/lib.rs | 7 ++++++- crates/mytheclipse-storage/src/lib.rs | 13 ++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/mytheclipse-cache/src/lib.rs b/crates/mytheclipse-cache/src/lib.rs index 2a396d4..76df1e2 100644 --- a/crates/mytheclipse-cache/src/lib.rs +++ b/crates/mytheclipse-cache/src/lib.rs @@ -17,9 +17,12 @@ //! //! ## Example //! +//! Multi-layer + cache-aside composition (default features): +//! //! ```no_run -//! use mytheclipse_cache::{Cache, MemoryCache, MultiLayerCache, CacheAside}; +//! # #[cfg(all(feature = "l1-memory", feature = "cache-aside"))] //! # async fn run() { +//! use mytheclipse_cache::{Cache, MemoryCache, MultiLayerCache, CacheAside}; //! let l1 = MemoryCache::new(); //! let l2 = MemoryCache::new(); // in a real app: a RedisCache //! let cache = MultiLayerCache::new(l1, l2); @@ -34,6 +37,8 @@ //! ); //! let _v = aside.get("orders:42").await.unwrap(); //! # } +//! # #[cfg(not(all(feature = "l1-memory", feature = "cache-aside")))] +//! # fn run() {} //! ``` #![forbid(unsafe_code)] diff --git a/crates/mytheclipse-storage/src/lib.rs b/crates/mytheclipse-storage/src/lib.rs index 717aeb0..df35f42 100644 --- a/crates/mytheclipse-storage/src/lib.rs +++ b/crates/mytheclipse-storage/src/lib.rs @@ -15,15 +15,22 @@ //! //! ## Example //! -//! ``` -//! use mytheclipse_storage::{LocalFileStorage, StorageDriver, bytes_stream, read_to_vec}; -//! # #[tokio::main] async fn main() { +//! Local disk storage (`local` feature, default): +//! +//! ```no_run +//! use mytheclipse_storage::{StorageDriver, bytes_stream, read_to_vec}; +//! # #[cfg(feature = "local")] +//! # #[tokio::main] +//! # async fn main() { +//! use mytheclipse_storage::LocalFileStorage; //! # let dir = tempfile::tempdir().unwrap(); //! let storage = LocalFileStorage::new(dir.path()); //! storage.put("hello.txt", bytes_stream(b"hi".to_vec())).await.unwrap(); //! let data = read_to_vec(storage.get("hello.txt").await.unwrap()).await.unwrap(); //! assert_eq!(data, b"hi"); //! # } +//! # #[cfg(not(feature = "local"))] +//! # fn main() {} //! ``` pub mod traits;