Add rustdoc JSON tests for #[doc(hidden)] handling of items.

This commit is contained in:
Predrag Gruevski
2025-07-09 01:32:23 +00:00
parent ab68b0fb26
commit 27fb02c947
2 changed files with 36 additions and 0 deletions
@@ -0,0 +1,19 @@
#![no_std]
// Without `--document-hidden-items`,
// none of these items are present in rustdoc JSON.
//@ !has "$.index[?(@.name=='func')]"
#[doc(hidden)]
pub fn func() {}
//@ !has "$.index[?(@.name=='Unit')]"
#[doc(hidden)]
pub struct Unit;
//@ !has "$.index[?(@.name=='hidden')]"
#[doc(hidden)]
pub mod hidden {
//@ !has "$.index[?(@.name=='Inner')]"
pub struct Inner;
}
@@ -0,0 +1,17 @@
//@ compile-flags: --document-hidden-items
#![no_std]
//@ is "$.index[?(@.name=='func')].attrs" '["#[doc(hidden)]"]'
#[doc(hidden)]
pub fn func() {}
//@ is "$.index[?(@.name=='Unit')].attrs" '["#[doc(hidden)]"]'
#[doc(hidden)]
pub struct Unit;
//@ is "$.index[?(@.name=='hidden')].attrs" '["#[doc(hidden)]"]'
#[doc(hidden)]
pub mod hidden {
//@ is "$.index[?(@.name=='Inner')].attrs" '[]'
pub struct Inner;
}