Skip to content

Commit fad92ca

Browse files
committed
Reexports show the 👻 indicator instead of an inline #[doc(hidden)] attribute
1 parent 00c605f commit fad92ca

2 files changed

Lines changed: 22 additions & 17 deletions

File tree

‎src/librustdoc/html/render/print_item.rs‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,19 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
340340
}
341341

342342
for (_, myitem) in &not_stripped_items[&type_] {
343+
let visibility_and_hidden = |item: &clean::Item| match item.visibility(tcx) {
344+
Some(ty::Visibility::Restricted(_)) => {
345+
if item.is_doc_hidden() {
346+
// Don't separate with a space when there are two of them
347+
"<span title=\"Restricted Visibility\">&nbsp;🔒</span><span title=\"Hidden item\">👻</span> "
348+
} else {
349+
"<span title=\"Restricted Visibility\">&nbsp;🔒</span> "
350+
}
351+
}
352+
_ if item.is_doc_hidden() => "<span title=\"Hidden item\">&nbsp;👻</span> ",
353+
_ => "",
354+
};
355+
343356
match myitem.kind {
344357
clean::ExternCrateItem { ref src } => {
345358
use crate::html::format::print_anchor;
@@ -377,6 +390,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
377390
print_extra_info_tags(tcx, myitem, item, Some(import_def_id))
378391
.to_string()
379392
});
393+
let visibility_and_hidden = visibility_and_hidden(myitem);
380394
let id = match import.kind {
381395
clean::ImportKind::Simple(s) => {
382396
format!(" id=\"{}\"", cx.derive_id(format!("reexport.{s}")))
@@ -388,13 +402,13 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
388402
"<dt{id}>\
389403
<code>"
390404
)?;
391-
render_attributes_in_code(w, myitem, "", cx)?;
392405
write!(
393406
w,
394-
"{vis}{imp}</code>{stab_tags}\
407+
"{vis}{imp}</code>{visibility_and_hidden}{stab_tags}\
395408
</dt>",
396409
vis = visibility_print_with_space(myitem, cx),
397410
imp = print_import(import, cx),
411+
visibility_and_hidden = visibility_and_hidden,
398412
)?;
399413
}
400414
_ => {
@@ -414,20 +428,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
414428
}
415429
_ => "",
416430
};
417-
let visibility_and_hidden = match myitem.visibility(tcx) {
418-
Some(ty::Visibility::Restricted(_)) => {
419-
if myitem.is_doc_hidden() {
420-
// Don't separate with a space when there are two of them
421-
"<span title=\"Restricted Visibility\">&nbsp;🔒</span><span title=\"Hidden item\">👻</span> "
422-
} else {
423-
"<span title=\"Restricted Visibility\">&nbsp;🔒</span> "
424-
}
425-
}
426-
_ if myitem.is_doc_hidden() => {
427-
"<span title=\"Hidden item\">&nbsp;👻</span> "
428-
}
429-
_ => "",
430-
};
431+
let visibility_and_hidden = visibility_and_hidden(myitem);
431432

432433
let docs = MarkdownSummaryLine(&myitem.doc_value(), &myitem.links(cx))
433434
.into_string();

‎tests/rustdoc-html/display-hidden-items.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
//@ has 'foo/index.html'
88
//@ has - '//dt/span[@title="Hidden item"]' '👻'
99

10-
//@ has - '//*[@id="reexport.hidden_reexport"]/code/*[@class="code-attribute"]' '#[doc(hidden)]'
10+
//@ matchesraw 'foo/index.html' '(?s)<dt><code><div class="code-attribute">#\[doc\(hidden\)\]</div>pub extern crate .*?hidden_(?:<wbr>)?core;</code></dt>'
11+
#[doc(hidden)]
12+
pub extern crate core as hidden_core;
13+
14+
//@ has - '//*[@id="reexport.hidden_reexport"]/span[@title="Hidden item"]' '👻'
1115
//@ has - '//*[@id="reexport.hidden_reexport"]/code' 'pub use hidden::inside_hidden as hidden_reexport;'
1216
#[doc(hidden)]
1317
pub use hidden::inside_hidden as hidden_reexport;

0 commit comments

Comments
 (0)