Skip to content

Commit 303029f

Browse files
Add "global" rustdoc test for RFC 3631
1 parent 645ca78 commit 303029f

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

tests/rustdoc/doc_auto_cfg.rs

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Test covering RFC 3631 features.
2+
3+
#![crate_name = "foo"]
4+
#![feature(no_core)]
5+
#![no_core]
6+
#![no_std]
7+
8+
#![doc(auto_cfg(hide(feature = "hidden")))]
9+
10+
//@ has 'foo/index.html'
11+
//@ !has - '//*[@class="stab portability"]' 'Non-moustache'
12+
//@ has - '//*[@class="stab portability"]' 'Non-pistache'
13+
//@ count - '//*[@class="stab portability"]' 1
14+
15+
//@ has 'foo/m/index.html'
16+
//@ count - '//*[@title="Available on non-crate feature `hidden` only"]' 2
17+
#[cfg(not(feature = "hidden"))]
18+
pub mod m {
19+
//@ count 'foo/m/struct.A.html' '//*[@class="stab portability"]' 0
20+
pub struct A;
21+
22+
//@ has 'foo/m/inner/index.html' '//*[@class="stab portability"]' 'Available on non-crate feature hidden only.'
23+
#[doc(auto_cfg(show(feature = "hidden")))]
24+
pub mod inner {
25+
//@ has 'foo/m/inner/struct.B.html' '//*[@class="stab portability"]' 'Available on non-crate feature hidden only.'
26+
pub struct B;
27+
28+
//@ count 'foo/m/inner/struct.A.html' '//*[@class="stab portability"]' 0
29+
#[doc(auto_cfg(hide(feature = "hidden")))]
30+
pub struct A;
31+
}
32+
33+
//@ has 'foo/m/struct.B.html' '//*[@class="stab portability"]' 'Available on non-crate feature hidden only.'
34+
#[doc(auto_cfg(show(feature = "hidden")))]
35+
pub struct B;
36+
}
37+
38+
//@ count 'foo/n/index.html' '//*[@title="Available on non-crate feature `moustache` only"]' 3
39+
//@ count - '//dl/dt' 4
40+
#[cfg(not(feature = "moustache"))]
41+
#[doc(auto_cfg = false)]
42+
pub mod n {
43+
// Should not have `moustache` listed.
44+
//@ count 'foo/n/struct.X.html' '//*[@class="stab portability"]' 0
45+
pub struct X;
46+
47+
// Should re-enable `auto_cfg` and make `moustache` listed.
48+
//@ has 'foo/n/struct.Y.html' '//*[@class="stab portability"]' \
49+
// 'Available on non-crate feature moustache only.'
50+
#[doc(auto_cfg)]
51+
pub struct Y;
52+
53+
// Should re-enable `auto_cfg` and make `moustache` listed for itself
54+
// and for `Y`.
55+
//@ has 'foo/n/inner/index.html' '//*[@class="stab portability"]' \
56+
// 'Available on non-crate feature moustache only.'
57+
#[doc(auto_cfg = true)]
58+
pub mod inner {
59+
//@ has 'foo/n/inner/struct.Y.html' '//*[@class="stab portability"]' \
60+
// 'Available on non-crate feature moustache only.'
61+
pub struct Y;
62+
}
63+
64+
// Should re-enable `auto_cfg` and make `moustache` listed.
65+
//@ has 'foo/n/struct.Z.html' '//*[@class="stab portability"]' \
66+
// 'Available on non-crate feature moustache only.'
67+
#[doc(auto_cfg(hide(feature = "hidden")))]
68+
pub struct Z;
69+
}
70+
71+
// Checking inheritance.
72+
//@ has 'foo/o/index.html' '//*[@class="stab portability"]' \
73+
// 'Available on non-crate feature pistache only.'
74+
#[doc(cfg(not(feature = "pistache")))]
75+
pub mod o {
76+
//@ has 'foo/o/struct.A.html' '//*[@class="stab portability"]' \
77+
// 'Available on non-crate feature pistache and non-crate feature tarte only.'
78+
#[doc(cfg(not(feature = "tarte")))]
79+
pub struct A;
80+
}

0 commit comments

Comments
 (0)