auto merge of #11461 : alexcrichton/rust/rustdoc-fixes, r=brson
See the commits.
This commit is contained in:
@@ -308,6 +308,7 @@ $(eval $(call libdoc,std,$(STDLIB_CRATE),$(CFG_BUILD)))
|
|||||||
$(eval $(call libdoc,extra,$(EXTRALIB_CRATE),$(CFG_BUILD)))
|
$(eval $(call libdoc,extra,$(EXTRALIB_CRATE),$(CFG_BUILD)))
|
||||||
$(eval $(call libdoc,native,$(LIBNATIVE_CRATE),$(CFG_BUILD)))
|
$(eval $(call libdoc,native,$(LIBNATIVE_CRATE),$(CFG_BUILD)))
|
||||||
$(eval $(call libdoc,green,$(LIBGREEN_CRATE),$(CFG_BUILD)))
|
$(eval $(call libdoc,green,$(LIBGREEN_CRATE),$(CFG_BUILD)))
|
||||||
|
$(eval $(call libdoc,rustuv,$(LIBRUSTUV_CRATE),$(CFG_BUILD)))
|
||||||
|
|
||||||
$(eval $(call compiledoc,rustc,$(COMPILER_CRATE),$(CFG_BUILD)))
|
$(eval $(call compiledoc,rustc,$(COMPILER_CRATE),$(CFG_BUILD)))
|
||||||
$(eval $(call compiledoc,syntax,$(LIBSYNTAX_CRATE),$(CFG_BUILD)))
|
$(eval $(call compiledoc,syntax,$(LIBSYNTAX_CRATE),$(CFG_BUILD)))
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ pub struct Cache {
|
|||||||
priv stack: ~[~str],
|
priv stack: ~[~str],
|
||||||
priv parent_stack: ~[ast::NodeId],
|
priv parent_stack: ~[ast::NodeId],
|
||||||
priv search_index: ~[IndexItem],
|
priv search_index: ~[IndexItem],
|
||||||
|
priv privmod: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper struct to render all source code to HTML pages
|
/// Helper struct to render all source code to HTML pages
|
||||||
@@ -241,6 +242,7 @@ pub fn run(mut crate: clean::Crate, dst: Path) {
|
|||||||
parent_stack: ~[],
|
parent_stack: ~[],
|
||||||
search_index: ~[],
|
search_index: ~[],
|
||||||
extern_locations: HashMap::new(),
|
extern_locations: HashMap::new(),
|
||||||
|
privmod: false,
|
||||||
};
|
};
|
||||||
cache.stack.push(crate.name.clone());
|
cache.stack.push(crate.name.clone());
|
||||||
crate = cache.fold_crate(crate);
|
crate = cache.fold_crate(crate);
|
||||||
@@ -455,6 +457,16 @@ impl<'a> SourceCollector<'a> {
|
|||||||
|
|
||||||
impl DocFolder for Cache {
|
impl DocFolder for Cache {
|
||||||
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
|
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
|
||||||
|
// If this is a private module, we don't want it in the search index.
|
||||||
|
let orig_privmod = match item.inner {
|
||||||
|
clean::ModuleItem(..) => {
|
||||||
|
let prev = self.privmod;
|
||||||
|
self.privmod = prev || item.visibility != Some(ast::Public);
|
||||||
|
prev
|
||||||
|
}
|
||||||
|
_ => self.privmod,
|
||||||
|
};
|
||||||
|
|
||||||
// Register any generics to their corresponding string. This is used
|
// Register any generics to their corresponding string. This is used
|
||||||
// when pretty-printing types
|
// when pretty-printing types
|
||||||
match item.inner {
|
match item.inner {
|
||||||
@@ -530,7 +542,7 @@ impl DocFolder for Cache {
|
|||||||
_ => Some((None, self.stack.as_slice()))
|
_ => Some((None, self.stack.as_slice()))
|
||||||
};
|
};
|
||||||
match parent {
|
match parent {
|
||||||
Some((parent, path)) => {
|
Some((parent, path)) if !self.privmod => {
|
||||||
self.search_index.push(IndexItem {
|
self.search_index.push(IndexItem {
|
||||||
ty: shortty(&item),
|
ty: shortty(&item),
|
||||||
name: s.to_owned(),
|
name: s.to_owned(),
|
||||||
@@ -539,7 +551,7 @@ impl DocFolder for Cache {
|
|||||||
parent: parent,
|
parent: parent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
None => {}
|
Some(..) | None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
@@ -612,8 +624,12 @@ impl DocFolder for Cache {
|
|||||||
// Private modules may survive the strip-private pass if
|
// Private modules may survive the strip-private pass if
|
||||||
// they contain impls for public types, but those will get
|
// they contain impls for public types, but those will get
|
||||||
// stripped here
|
// stripped here
|
||||||
clean::Item { inner: clean::ModuleItem(ref m), .. }
|
clean::Item { inner: clean::ModuleItem(ref m),
|
||||||
if m.items.len() == 0 => None,
|
visibility, .. }
|
||||||
|
if (m.items.len() == 0 &&
|
||||||
|
item.doc_value().is_none()) ||
|
||||||
|
visibility != Some(ast::Public) => None,
|
||||||
|
|
||||||
i => Some(i),
|
i => Some(i),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -622,6 +638,7 @@ impl DocFolder for Cache {
|
|||||||
|
|
||||||
if pushed { self.stack.pop(); }
|
if pushed { self.stack.pop(); }
|
||||||
if parent_pushed { self.parent_stack.pop(); }
|
if parent_pushed { self.parent_stack.pop(); }
|
||||||
|
self.privmod = orig_privmod;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1186,7 +1203,7 @@ fn item_struct(w: &mut Writer, it: &clean::Item, s: &clean::Struct) {
|
|||||||
|
|
||||||
document(w, it);
|
document(w, it);
|
||||||
match s.struct_type {
|
match s.struct_type {
|
||||||
doctree::Plain => {
|
doctree::Plain if s.fields.len() > 0 => {
|
||||||
write!(w, "<h2 class='fields'>Fields</h2>\n<table>");
|
write!(w, "<h2 class='fields'>Fields</h2>\n<table>");
|
||||||
for field in s.fields.iter() {
|
for field in s.fields.iter() {
|
||||||
write!(w, "<tr><td id='structfield.{name}'>\
|
write!(w, "<tr><td id='structfield.{name}'>\
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ pub fn opts() -> ~[groups::OptGroup] {
|
|||||||
use extra::getopts::groups::*;
|
use extra::getopts::groups::*;
|
||||||
~[
|
~[
|
||||||
optflag("h", "help", "show this help message"),
|
optflag("h", "help", "show this help message"),
|
||||||
|
optflag("", "version", "print rustdoc's version"),
|
||||||
optopt("r", "input-format", "the input type of the specified file",
|
optopt("r", "input-format", "the input type of the specified file",
|
||||||
"[rust|json]"),
|
"[rust|json]"),
|
||||||
optopt("w", "output-format", "the output type to write",
|
optopt("w", "output-format", "the output type to write",
|
||||||
@@ -119,6 +120,9 @@ pub fn main_args(args: &[~str]) -> int {
|
|||||||
if matches.opt_present("h") || matches.opt_present("help") {
|
if matches.opt_present("h") || matches.opt_present("help") {
|
||||||
usage(args[0]);
|
usage(args[0]);
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if matches.opt_present("version") {
|
||||||
|
rustc::version(args[0]);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.free.len() == 0 {
|
if matches.free.len() == 0 {
|
||||||
|
|||||||
@@ -136,7 +136,9 @@ impl<'a> fold::DocFolder for Stripper<'a> {
|
|||||||
Some(i) => {
|
Some(i) => {
|
||||||
match i.inner {
|
match i.inner {
|
||||||
// emptied modules/impls have no need to exist
|
// emptied modules/impls have no need to exist
|
||||||
clean::ModuleItem(ref m) if m.items.len() == 0 => None,
|
clean::ModuleItem(ref m)
|
||||||
|
if m.items.len() == 0 &&
|
||||||
|
i.doc_value().is_none() => None,
|
||||||
clean::ImplItem(ref i) if i.methods.len() == 0 => None,
|
clean::ImplItem(ref i) if i.methods.len() == 0 => None,
|
||||||
_ => {
|
_ => {
|
||||||
self.retained.insert(i.id);
|
self.retained.insert(i.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user