rustdoc: Strip imports of items which are #[doc(hidden)]
Closes #106379
This commit is contained in:
parent
7bbbaabbb6
commit
ff46d116c1
4 changed files with 29 additions and 1 deletions
|
|
@ -2494,6 +2494,17 @@ impl Import {
|
|||
pub(crate) fn new_glob(source: ImportSource, should_be_displayed: bool) -> Self {
|
||||
Self { kind: ImportKind::Glob, source, should_be_displayed }
|
||||
}
|
||||
|
||||
pub(crate) fn imported_item_is_doc_hidden(&self, tcx: TyCtxt<'_>) -> bool {
|
||||
match self.source.did {
|
||||
Some(did) => tcx
|
||||
.get_attrs(did, sym::doc)
|
||||
.filter_map(ast::Attribute::meta_item_list)
|
||||
.flatten()
|
||||
.has_word(sym::hidden),
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
|
|||
|
|
@ -248,6 +248,7 @@ pub(crate) struct ImportStripper<'tcx> {
|
|||
impl<'tcx> DocFolder for ImportStripper<'tcx> {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
match *i.kind {
|
||||
clean::ImportItem(imp) if imp.imported_item_is_doc_hidden(self.tcx) => None,
|
||||
clean::ExternCrateItem { .. } | clean::ImportItem(..)
|
||||
if i.visibility(self.tcx) != Some(Visibility::Public) =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue