diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-07-10 20:28:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-10 20:28:51 +0200 |
| commit | b5d1b92a8c7241cc6989e3b5d0246654c4065679 (patch) | |
| tree | f4adeccd162918f1ce1e629fecc8b52db131e222 /tests | |
| parent | 6c4502d97d176bbc5bc14ee25f471abd463b0b1c (diff) | |
| parent | 27fb02c947a3aec673364ee555c0c24d8215b7c7 (diff) | |
| download | rust-b5d1b92a8c7241cc6989e3b5d0246654c4065679.tar.gz rust-b5d1b92a8c7241cc6989e3b5d0246654c4065679.zip | |
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`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/rustdoc-json/visibility/doc_hidden_default.rs | 19 | ||||
| -rw-r--r-- | tests/rustdoc-json/visibility/doc_hidden_documented.rs | 17 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/rustdoc-json/visibility/doc_hidden_default.rs b/tests/rustdoc-json/visibility/doc_hidden_default.rs new file mode 100644 index 00000000000..3fa91b3c4ad --- /dev/null +++ b/tests/rustdoc-json/visibility/doc_hidden_default.rs @@ -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; +} diff --git a/tests/rustdoc-json/visibility/doc_hidden_documented.rs b/tests/rustdoc-json/visibility/doc_hidden_documented.rs new file mode 100644 index 00000000000..6e9ef48680b --- /dev/null +++ b/tests/rustdoc-json/visibility/doc_hidden_documented.rs @@ -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; +} |
