Skip to content

Commit b5d1b92

Browse files
authored
Rollup merge of #143665 - obi1kenobi:pg/doc-hidden-tests, r=aDotInTheVoid
[rustdoc-json] Add tests for `#[doc(hidden)]` handling of items. Add tests which check: - `#[doc(hidden)]` items are not present in rustdoc JSON output by default. - Invoking rustdoc with `--document-hidden-items` makes `#[doc(hidden)]` items appear, and they show their `#[doc(hidden)]` status appropriately. r? `@aDotInTheVoid`
2 parents 6c4502d + 27fb02c commit b5d1b92

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-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+
}

0 commit comments

Comments
 (0)