1 //! Strip all private items from the output. Additionally implies strip_priv_imports.
2 //! Basically, the goal is to remove items that are not relevant for public documentation.
3 use crate::clean::{self, ItemIdSet};
4 use crate::core::DocContext;
5 use crate::fold::DocFolder;
6 use crate::passes::{ImplStripper, ImportStripper, Pass, Stripper};
8 crate const STRIP_PRIVATE: Pass = Pass {
11 description: "strips all private items from a crate which cannot be seen externally, \
12 implies strip-priv-imports",
15 /// Strip private items from the point of view of a crate or externally from a
16 /// crate, specified by the `xcrate` flag.
17 crate fn strip_private(mut krate: clean::Crate, cx: &mut DocContext<'_>) -> clean::Crate {
18 // This stripper collects all *retained* nodes.
19 let mut retained = ItemIdSet::default();
21 // strip all private items
23 let mut stripper = Stripper {
24 retained: &mut retained,
25 access_levels: &cx.cache.access_levels,
26 update_retained: true,
28 krate = ImportStripper.fold_crate(stripper.fold_crate(krate));
31 // strip all impls referencing private items
32 let mut stripper = ImplStripper { retained: &retained, cache: &cx.cache };
33 stripper.fold_crate(krate)