Skip to content

Commit 0dfd729

Browse files
committed
[rustdoc] Add tests for #[doc(hidden)] handling of items.
1 parent ab68b0f commit 0dfd729

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![no_std]
2+
3+
// Without `--document-hidden-items`,
4+
// none of these items are present in rustdoc JSON.
5+
6+
//@ !has "$.index[?(@.name=='func')]"
7+
#[doc(hidden)]
8+
pub fn func() {}
9+
10+
//@ !has "$.index[?(@.name=='Unit')]"
11+
#[doc(hidden)]
12+
pub struct Unit;
13+
14+
//@ !has "$.index[?(@.name=='hidden')]"
15+
#[doc(hidden)]
16+
pub mod hidden {
17+
//@ !has "$.index[?(@.name=='Inner')]"
18+
pub struct Inner;
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ compile-flags: --document-hidden-items
2+
#![no_std]
3+
4+
//@ is "$.index[?(@.name=='func')].attrs" '["#[doc(hidden)]"]'
5+
#[doc(hidden)]
6+
pub fn func() {}
7+
8+
//@ is "$.index[?(@.name=='Unit')].attrs" '["#[doc(hidden)]"]'
9+
#[doc(hidden)]
10+
pub struct Unit;
11+
12+
//@ is "$.index[?(@.name=='hidden')].attrs" '["#[doc(hidden)]"]'
13+
#[doc(hidden)]
14+
pub mod hidden {
15+
//@ is "$.index[?(@.name=='Inner')].attrs" '[]'
16+
pub struct Inner;
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![crate_name = "foo"]
2+
3+
// Without `--document-hidden-items`,
4+
// none of these items are present in rustdoc output.
5+
6+
//@ !has foo/fn.func.html
7+
#[doc(hidden)]
8+
pub fn func() {}
9+
10+
//@ !has foo/struct.Unit.html
11+
#[doc(hidden)]
12+
pub struct Unit;
13+
14+
//@ !has foo/hidden/index.html
15+
#[doc(hidden)]
16+
pub mod hidden {
17+
//@ !has foo/hidden/struct.Inner.html
18+
pub struct Inner;
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ compile-flags: -Z unstable-options --document-hidden-items
2+
#![crate_name = "foo"]
3+
4+
//@ has foo/fn.func.html
5+
//@ has foo/fn.func.html '//pre[@class="rust item-decl"]' '#[doc(hidden)]'
6+
#[doc(hidden)]
7+
pub fn func() {}
8+
9+
//@ has foo/struct.Unit.html
10+
//@ has foo/struct.Unit.html '//pre[@class="rust item-decl"]' '#[doc(hidden)]'
11+
#[doc(hidden)]
12+
pub struct Unit;
13+
14+
// FIXME: It isn't clear how to check if this module is marked hidden within
15+
// the current XPath engine and with the current HTML structure.
16+
// The module name and the hidden-ness element are siblings, not parent-child,
17+
// which seems to make the XPath query run into engine limitations and fail.
18+
//@ has foo/hidden/index.html
19+
#[doc(hidden)]
20+
pub mod hidden {
21+
//@ has foo/hidden/struct.Inner.html
22+
//@ !has foo/hidden/struct.Inner.html '//pre[@class="rust item-decl"]' '#[doc(hidden)]'
23+
pub struct Inner;
24+
}

0 commit comments

Comments
 (0)