about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-05-24 23:01:12 +0200
committerGitHub <noreply@github.com>2024-05-24 23:01:12 +0200
commitf1eef384bba4090c7f2c9a6482dccad6dcf4e160 (patch)
treebfdb6effea956bd11d4fc5c16000ba43ec38b94d
parent104e1a4bf2395fb1ad107cb102920fba9e11ed7e (diff)
parent3ee84983f1a0cf1fe0be0d0fb024be9e2eb6fd13 (diff)
downloadrust-f1eef384bba4090c7f2c9a6482dccad6dcf4e160.tar.gz
rust-f1eef384bba4090c7f2c9a6482dccad6dcf4e160.zip
Rollup merge of #125503 - aDotInTheVoid:rdj-keyword-attr, r=GuillaumeGomez
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`
-rw-r--r--tests/rustdoc-json/keyword_private.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/rustdoc-json/keyword_private.rs b/tests/rustdoc-json/keyword_private.rs
new file mode 100644
index 00000000000..1c2b7d02155
--- /dev/null
+++ b/tests/rustdoc-json/keyword_private.rs
@@ -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 {}