Skip to content

Commit

Permalink
Rollup merge of #125503 - aDotInTheVoid:rdj-keyword-attr, r=Guillaume…
Browse files Browse the repository at this point in the history
…Gomez

rustdoc-json: Add test for keywords with `--document-private-items`

Turns out this does work as-expected. I was worried that the rustdoc's clean would produce a `ItemKind::KeywordItem` for the module, and loose the module itself. But turns out we get this right.

Prompted by [this discussion on zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Where.20to.20find.20keyword.20entries.20in.20JSON.20rustdoc)

r? `@GuillaumeGomez`
  • Loading branch information
matthiaskrgr committed May 24, 2024
2 parents 104e1a4 + 3ee8498 commit f1eef38
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/rustdoc-json/keyword_private.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Ensure keyword docs are present with --document-private-items

//@ compile-flags: --document-private-items
#![feature(rustdoc_internals)]

// @!has "$.index[*][?(@.name=='match')]"
// @has "$.index[*][?(@.name=='foo')]"
// @is "$.index[*][?(@.name=='foo')].attrs" '["#[doc(keyword = \"match\")]"]'
// @is "$.index[*][?(@.name=='foo')].docs" '"this is a test!"'
#[doc(keyword = "match")]
/// this is a test!
pub mod foo {}

// @!has "$.index[*][?(@.name=='hello')]"
// @has "$.index[*][?(@.name=='bar')]"
// @is "$.index[*][?(@.name=='bar')].attrs" '["#[doc(keyword = \"hello\")]"]'
// @is "$.index[*][?(@.name=='bar')].docs" '"hello"'
#[doc(keyword = "hello")]
/// hello
mod bar {}

0 comments on commit f1eef38

Please sign in to comment.