Skip to content

Commit 1f64820

Browse files
committed
rustdoc: Private modules can be included in docs
Changed `rustdoc` so that if we do not have the `strip-private` pass enabled private modules will be included in the generated documentation. Also changed `strip-private` pass to actually remove private modules.
1 parent f187573 commit 1f64820

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/librustdoc/html/render.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ impl Context {
11931193
// these modules are recursed into, but not rendered normally (a
11941194
// flag on the context).
11951195
if !self.render_redirect_pages {
1196-
self.render_redirect_pages = ignore_private_item(&item);
1196+
self.render_redirect_pages = ignore_empty_item(&item);
11971197
}
11981198

11991199
match item.inner {
@@ -1444,7 +1444,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
14441444
try!(document(w, item));
14451445

14461446
let mut indices = range(0, items.len()).filter(|i| {
1447-
!ignore_private_item(&items[*i])
1447+
!ignore_empty_item(&items[*i])
14481448
}).collect::<Vec<uint>>();
14491449

14501450
fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: uint, idx2: uint) -> Ordering {
@@ -2161,7 +2161,7 @@ impl<'a> fmt::Show for Sidebar<'a> {
21612161
fn build_sidebar(m: &clean::Module) -> HashMap<String, Vec<String>> {
21622162
let mut map = HashMap::new();
21632163
for item in m.items.iter() {
2164-
if ignore_private_item(item) { continue }
2164+
if ignore_empty_item(item) { continue }
21652165

21662166
let short = shortty(item).to_static_str();
21672167
let myname = match item.name {
@@ -2215,11 +2215,10 @@ fn item_primitive(w: &mut fmt::Formatter,
22152215
render_methods(w, it)
22162216
}
22172217

2218-
fn ignore_private_item(it: &clean::Item) -> bool {
2218+
fn ignore_empty_item(it: &clean::Item) -> bool {
22192219
match it.inner {
22202220
clean::ModuleItem(ref m) => {
2221-
(m.items.len() == 0 && it.doc_value().is_none()) ||
2222-
it.visibility != Some(ast::Public)
2221+
(m.items.len() == 0 && it.doc_value().is_none())
22232222
}
22242223
clean::PrimitiveItem(..) => it.visibility != Some(ast::Public),
22252224
_ => false,

src/librustdoc/passes.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,11 @@ impl<'a> fold::DocFolder for Stripper<'a> {
168168
}
169169
}
170170

171-
// handled below
172-
clean::ModuleItem(..) => {}
171+
clean::ModuleItem(..) => {
172+
if i.visibility != Some(ast::Public) {
173+
return None
174+
}
175+
}
173176

174177
// trait impls for private items should be stripped
175178
clean::ImplItem(clean::Impl{

0 commit comments

Comments
 (0)