Skip to content

Commit d9753d7

Browse files
Add tests for --document-hidden-items option
1 parent 8e8c5c9 commit d9753d7

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

tests/rustdoc/display-hidden-items.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Test to ensure that the `--document-hidden-items` option is working as expected.
2+
// compile-flags: -Z unstable-options --document-hidden-items
3+
// ignore-tidy-linelength
4+
5+
#![crate_name = "foo"]
6+
7+
// @has 'foo/index.html'
8+
// @has - '//*[@id="reexport.hidden_reexport"]/code' 'pub use hidden::inside_hidden as hidden_reexport;'
9+
#[doc(hidden)]
10+
pub use hidden::inside_hidden as hidden_reexport;
11+
12+
// @has - '//*[@class="item-name"]/a[@class="trait"]' 'TraitHidden'
13+
// @has 'foo/trait.TraitHidden.html'
14+
#[doc(hidden)]
15+
pub trait TraitHidden {}
16+
17+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="trait"]' 'Trait'
18+
pub trait Trait {
19+
// @has 'foo/trait.Trait.html'
20+
// @has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' 'const BAR: u32 = 0u32'
21+
#[doc(hidden)]
22+
const BAR: u32 = 0;
23+
24+
// @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()'
25+
#[doc(hidden)]
26+
fn foo() {}
27+
}
28+
29+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="struct"]' 'Struct'
30+
// @has 'foo/struct.Struct.html'
31+
pub struct Struct {
32+
// @has - '//*[@id="structfield.a"]/code' 'a: u32'
33+
#[doc(hidden)]
34+
pub a: u32,
35+
}
36+
37+
impl Struct {
38+
// @has - '//*[@id="method.new"]/*[@class="code-header"]' 'pub fn new() -> Self'
39+
#[doc(hidden)]
40+
pub fn new() -> Self { Self { a: 0 } }
41+
}
42+
43+
impl Trait for Struct {
44+
// @has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' 'const BAR: u32 = 0u32'
45+
// @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()'
46+
}
47+
// @has - '//*[@id="impl-TraitHidden-for-Struct"]/*[@class="code-header"]' 'impl TraitHidden for Struct'
48+
impl TraitHidden for Struct {}
49+
50+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'HiddenEnum'
51+
// @has 'foo/enum.HiddenEnum.html'
52+
#[doc(hidden)]
53+
pub enum HiddenEnum {
54+
A,
55+
}
56+
57+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="enum"]' 'Enum'
58+
pub enum Enum {
59+
// @has 'foo/enum.Enum.html' '//*[@id="variant.A"]/*[@class="code-header"]' 'A'
60+
#[doc(hidden)]
61+
A,
62+
}
63+
64+
// @has 'foo/index.html' '//*[@class="item-name"]/a[@class="mod"]' 'hidden'
65+
#[doc(hidden)]
66+
pub mod hidden {
67+
// @has 'foo/hidden/index.html'
68+
// @has - '//*[@class="item-name"]/a[@class="fn"]' 'inside_hidden'
69+
// @has 'foo/hidden/fn.inside_hidden.html'
70+
pub fn inside_hidden() {}
71+
}

0 commit comments

Comments
 (0)