Skip to content

Commit 32ca89a

Browse files
committed
---
yaml --- r: 97613 b: refs/heads/snap-stage3 c: 5948079 h: refs/heads/master i: 97611: 9d16423 v: v3
1 parent 1656cbe commit 32ca89a

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 79e144ed64866d5a6d2c5f1789cca80d1627578e
4+
refs/heads/snap-stage3: 594807951f0a7761ad31642168fd3728b78923dc
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustdoc/html/render.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub struct Cache {
157157
priv stack: ~[~str],
158158
priv parent_stack: ~[ast::NodeId],
159159
priv search_index: ~[IndexItem],
160+
priv privmod: bool,
160161
}
161162

162163
/// Helper struct to render all source code to HTML pages
@@ -241,6 +242,7 @@ pub fn run(mut crate: clean::Crate, dst: Path) {
241242
parent_stack: ~[],
242243
search_index: ~[],
243244
extern_locations: HashMap::new(),
245+
privmod: false,
244246
};
245247
cache.stack.push(crate.name.clone());
246248
crate = cache.fold_crate(crate);
@@ -455,6 +457,16 @@ impl<'a> SourceCollector<'a> {
455457

456458
impl DocFolder for Cache {
457459
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
460+
// If this is a private module, we don't want it in the search index.
461+
let orig_privmod = match item.inner {
462+
clean::ModuleItem(..) => {
463+
let prev = self.privmod;
464+
self.privmod = prev || item.visibility != Some(ast::public);
465+
prev
466+
}
467+
_ => self.privmod,
468+
};
469+
458470
// Register any generics to their corresponding string. This is used
459471
// when pretty-printing types
460472
match item.inner {
@@ -530,7 +542,7 @@ impl DocFolder for Cache {
530542
_ => Some((None, self.stack.as_slice()))
531543
};
532544
match parent {
533-
Some((parent, path)) => {
545+
Some((parent, path)) if !self.privmod => {
534546
self.search_index.push(IndexItem {
535547
ty: shortty(&item),
536548
name: s.to_owned(),
@@ -539,7 +551,7 @@ impl DocFolder for Cache {
539551
parent: parent,
540552
});
541553
}
542-
None => {}
554+
Some(..) | None => {}
543555
}
544556
}
545557
None => {}
@@ -612,8 +624,12 @@ impl DocFolder for Cache {
612624
// Private modules may survive the strip-private pass if
613625
// they contain impls for public types, but those will get
614626
// stripped here
615-
clean::Item { inner: clean::ModuleItem(ref m), .. }
616-
if m.items.len() == 0 => None,
627+
clean::Item { inner: clean::ModuleItem(ref m),
628+
visibility, .. }
629+
if (m.items.len() == 0 &&
630+
item.doc_value().is_none()) ||
631+
visibility != Some(ast::public) => None,
632+
617633
i => Some(i),
618634
}
619635
}
@@ -622,6 +638,7 @@ impl DocFolder for Cache {
622638

623639
if pushed { self.stack.pop(); }
624640
if parent_pushed { self.parent_stack.pop(); }
641+
self.privmod = orig_privmod;
625642
return ret;
626643
}
627644
}

0 commit comments

Comments
 (0)