Skip to content

Commit 04685cc

Browse files
committed
chore(dir-structure): move derive macros behind feature gate
1 parent b8b0de4 commit 04685cc

File tree

27 files changed

+323
-176
lines changed

27 files changed

+323
-176
lines changed

.github/workflows/test-dir-structure.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,23 @@ jobs:
3131
strategy:
3232
matrix:
3333
feature-combos: [
34-
"--features default",
35-
"--features assert_eq,default",
36-
"--features assert_eq,default,git",
34+
"--no-default-features",
35+
"--no-default-features --features assert_eq",
36+
"--no-default-features --features git",
37+
"--no-default-features --features async",
38+
"--no-default-features --features tokio",
39+
"--no-default-features --features image",
40+
"--no-default-features --features image,image-format-png",
41+
"--no-default-features --features image,image-format-jpeg",
42+
"--no-default-features --features resolve-path",
43+
"--no-default-features --features json",
44+
"--no-default-features --features toml",
45+
"--no-default-features --features yaml",
46+
"--no-default-features --features ron",
47+
"--no-default-features --features include_dir",
48+
"--no-default-features --features derive",
49+
"--features assert_eq",
50+
"--features assert_eq,git",
3751
"--features assert_eq,async",
3852
"--features assert_eq,tokio",
3953
"--features assert_eq,image",
@@ -76,9 +90,9 @@ jobs:
7690
with:
7791
save-if: ${{ matrix.feature-combos == '--all-features' && matrix.cmd == 'test' }}
7892
- name: Build dir-structure
79-
run: cargo build -p dir-structure --no-default-features ${{ matrix.feature-combos }}
93+
run: cargo build -p dir-structure ${{ matrix.feature-combos }}
8094
if: matrix.cmd == 'build'
8195

8296
- name: Run tests
83-
run: cargo test -p dir-structure --no-default-features ${{ matrix.feature-combos }} -- --test-threads=1
97+
run: cargo test -p dir-structure ${{ matrix.feature-combos }} -- --test-threads=1
8498
if: matrix.cmd == 'test'

doc/docs/content/docs/dx/dir-structure/.custom-impl.mdx.doctests

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,8 @@
277277
/// and write the modification time of files. Let's see how to use this wrapper
278278
/// in practice.
279279
///
280-
/// ```rust,no_run
280+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
281+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
281282
/// #![deny(unused_imports)]
282283
///
283284
/// use std::path::Path;

doc/docs/content/docs/dx/dir-structure/.guide.mdx.doctests

Lines changed: 72 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
/// `}
3333
/// />
3434
///
35-
/// ```rust,no_run
35+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
36+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
3637
/// #![deny(unused_imports)]
3738
///
3839
/// // !tooltip[/DirStructure/] DirStructure
@@ -68,7 +69,8 @@
6869
/// `}
6970
/// />
7071
///
71-
/// ```rust,no_run
72+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
73+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
7274
/// #![deny(unused_imports)]
7375
///
7476
/// // !tooltip[/DirStructure/] DirStructure
@@ -108,7 +110,8 @@
108110
/// `}
109111
/// />
110112
///
111-
/// ```rust,no_run
113+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
114+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
112115
/// #![deny(unused_imports)]
113116
///
114117
/// // !tooltip[/DirStructure/] DirStructure
@@ -156,52 +159,52 @@
156159
/// />
157160
///
158161
///
159-
#[cfg_attr(all(feature = "json", ), doc = r##########"```rust,no_run
160-
#![deny(unused_imports)]
161-
162-
// !tooltip[/DirStructure/] DirStructure
163-
// !tooltip[/DirStructureItem/] DirStructureItem
164-
// !tooltip[/FmtWrapper/] FmtWrapper
165-
// !tooltip[/Json/] Json
166-
use dir_structure::{DirStructure, traits::sync::DirStructureItem, fmt_wrapper::FmtWrapper, data_formats::json::Json};
167-
use serde::{Serialize, Deserialize};
168-
169-
// !tooltip[/DirStructure/] DirStructure
170-
#[derive(DirStructure)]
171-
struct Dir {
172-
#[dir_structure(path = "input.bin")]
173-
binary: Vec<u8>,
174-
#[dir_structure(
175-
path = "number.txt",
176-
// !tooltip[/FmtWrapper/] FmtWrapper
177-
with_newtype = FmtWrapper<u64>,
178-
)]
179-
number: u64,
180-
#[dir_structure(
181-
path = "f.json",
182-
// !mark
183-
// !tooltip[/Json/] Json
184-
with_newtype = Json<Obj>,
185-
)]
186-
f: Obj,
187-
}
188-
189-
// !mark(1:5)
190-
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
191-
struct Obj {
192-
name: String,
193-
age: u32,
194-
}
195-
196-
let path = "dir";
197-
// !tooltip[/read/] DirStructureItem::read#
198-
let dir = Dir::read(path)?;
199-
// !tooltip[/write/] DirStructureItem::write#
200-
dir.write(path)?;
201-
Ok::<_, dir_structure::error::Error>(())
202-
203-
```
204-
"##########)]
162+
#[cfg_attr(all(feature = "json", feature = "derive", ), doc = r#"```rust,no_run"#)]
163+
#[cfg_attr(not(all(feature = "json", feature = "derive", )), doc = r#"```rust,compile_fail"#)]
164+
/// #![deny(unused_imports)]
165+
///
166+
/// // !tooltip[/DirStructure/] DirStructure
167+
/// // !tooltip[/DirStructureItem/] DirStructureItem
168+
/// // !tooltip[/FmtWrapper/] FmtWrapper
169+
/// // !tooltip[/Json/] Json
170+
/// use dir_structure::{DirStructure, traits::sync::DirStructureItem, fmt_wrapper::FmtWrapper, data_formats::json::Json};
171+
/// use serde::{Serialize, Deserialize};
172+
///
173+
/// // !tooltip[/DirStructure/] DirStructure
174+
/// #[derive(DirStructure)]
175+
/// struct Dir {
176+
/// #[dir_structure(path = "input.bin")]
177+
/// binary: Vec<u8>,
178+
/// #[dir_structure(
179+
/// path = "number.txt",
180+
/// // !tooltip[/FmtWrapper/] FmtWrapper
181+
/// with_newtype = FmtWrapper<u64>,
182+
/// )]
183+
/// number: u64,
184+
/// #[dir_structure(
185+
/// path = "f.json",
186+
/// // !mark
187+
/// // !tooltip[/Json/] Json
188+
/// with_newtype = Json<Obj>,
189+
/// )]
190+
/// f: Obj,
191+
/// }
192+
///
193+
/// // !mark(1:5)
194+
/// #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
195+
/// struct Obj {
196+
/// name: String,
197+
/// age: u32,
198+
/// }
199+
///
200+
/// let path = "dir";
201+
/// // !tooltip[/read/] DirStructureItem::read#
202+
/// let dir = Dir::read(path)?;
203+
/// // !tooltip[/write/] DirStructureItem::write#
204+
/// dir.write(path)?;
205+
/// Ok::<_, dir_structure::error::Error>(())
206+
///
207+
/// ```
205208
///
206209
/// ## !!steps Let's go back to the basics
207210
///
@@ -217,7 +220,8 @@ Ok::<_, dir_structure::error::Error>(())
217220
/// />
218221
///
219222
///
220-
/// ```rust,no_run
223+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
224+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
221225
/// #![deny(unused_imports)]
222226
///
223227
/// // !tooltip[/DirStructure/] DirStructure
@@ -256,7 +260,8 @@ Ok::<_, dir_structure::error::Error>(())
256260
/// `}
257261
/// />
258262
///
259-
/// ```rust,no_run
263+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
264+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
260265
/// #![deny(unused_imports)]
261266
///
262267
/// // !tooltip[/DirStructure/] DirStructure
@@ -310,7 +315,8 @@ Ok::<_, dir_structure::error::Error>(())
310315
/// `}
311316
/// />
312317
///
313-
/// ```rust,no_run
318+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
319+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
314320
/// #![deny(unused_imports)]
315321
///
316322
/// // !tooltip[/DirStructure/] DirStructure
@@ -368,7 +374,10 @@ Ok::<_, dir_structure::error::Error>(())
368374
/// `}
369375
/// />
370376
///
371-
/// ```rust,no_run
377+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
378+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
379+
/// #![deny(unused_imports)]
380+
///
372381
/// use std::path::Path;
373382
/// // !tooltip[/DirStructure/] DirStructure
374383
/// // !tooltip[/DirStructureItem/] DirStructureItem
@@ -437,7 +446,8 @@ Ok::<_, dir_structure::error::Error>(())
437446
/// `}
438447
/// />
439448
///
440-
/// ```rust,no_run
449+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
450+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
441451
/// #![deny(unused_imports)]
442452
///
443453
/// // !tooltip[/ext_filter/] ext_filter
@@ -496,7 +506,8 @@ Ok::<_, dir_structure::error::Error>(())
496506
/// `}
497507
/// />
498508
///
499-
/// ```rust,no_run
509+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
510+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
500511
/// #![deny(unused_imports)]
501512
///
502513
/// // !tooltip[/ext_filter/] ext_filter
@@ -570,7 +581,8 @@ Ok::<_, dir_structure::error::Error>(())
570581
/// `}
571582
/// />
572583
///
573-
/// ```rust,no_run
584+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
585+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
574586
/// #![deny(unused_imports)]
575587
///
576588
/// // !tooltip[/ext_filter/] ext_filter
@@ -652,7 +664,8 @@ Ok::<_, dir_structure::error::Error>(())
652664
/// `}
653665
/// />
654666
///
655-
/// ```rust,no_run
667+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
668+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
656669
/// #![deny(unused_imports)]
657670
///
658671
/// // !tooltip[/ext_filter/] ext_filter
@@ -740,7 +753,8 @@ Ok::<_, dir_structure::error::Error>(())
740753
/// />
741754
///
742755
///
743-
/// ```rust,no_run
756+
#[cfg_attr(all(feature = "derive", ), doc = r#"```rust,no_run"#)]
757+
#[cfg_attr(not(all(feature = "derive", )), doc = r#"```rust,compile_fail"#)]
744758
/// #![deny(unused_imports)]
745759
///
746760
/// // !tooltip[/ext_filter/] ext_filter

doc/docs/content/docs/dx/dir-structure/custom-impl.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ in practice.
271271

272272
```rust ! code.rs no_run
273273
// !lints
274+
// !req-feature derive
274275
use std::path::Path;
275276
use std::pin::Pin;
276277
use std::time::SystemTime;

0 commit comments

Comments
 (0)