Merge remote-tracking branch 'brson/companion' into incoming

Conflicts:
	src/compiletest/compiletest.rs
	src/libcargo/cargo.rs
	src/libcore/core.rs
	src/librustc/rustc.rs
	src/librustdoc/rustdoc.rc
This commit is contained in:
Brian Anderson 2012-11-28 12:38:53 -08:00
commit fc06114ddf
150 changed files with 4316 additions and 8444 deletions

View file

@ -11,19 +11,9 @@ pub enum OutputFormat {
}
impl OutputFormat : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &OutputFormat) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &OutputFormat) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &OutputFormat) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &OutputFormat) -> bool { !(*self).eq(other) }
}
@ -36,19 +26,9 @@ pub enum OutputStyle {
}
impl OutputStyle : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &OutputStyle) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &OutputStyle) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &OutputStyle) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &OutputStyle) -> bool { !(*self).eq(other) }
}

View file

@ -7,19 +7,9 @@ pub type Doc_ = {
};
impl Doc_ : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Doc_) -> bool {
self.pages == (*other).pages
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Doc_) -> bool {
(*self).pages == (*other).pages
}
#[cfg(stage0)]
pure fn ne(other: &Doc_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Doc_) -> bool { !(*self).eq(other) }
}
@ -28,15 +18,7 @@ pub enum Doc {
}
impl Doc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Doc) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Doc) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &Doc) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Doc) -> bool { *(*self) != *(*other) }
}
@ -46,25 +28,6 @@ pub enum Page {
}
impl Page : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Page) -> bool {
match self {
CratePage(e0a) => {
match (*other) {
CratePage(e0b) => e0a == e0b,
_ => false
}
}
ItemPage(e0a) => {
match (*other) {
ItemPage(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Page) -> bool {
match (*self) {
CratePage(e0a) => {
@ -81,10 +44,6 @@ impl Page : cmp::Eq {
}
}
}
#[cfg(stage0)]
pure fn ne(other: &Page) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Page) -> bool { !(*self).eq(other) }
}
@ -94,19 +53,9 @@ pub enum Implementation {
}
impl Implementation : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Implementation) -> bool {
(self as uint) == ((*other) as uint)
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Implementation) -> bool {
((*self) as uint) == ((*other) as uint)
}
#[cfg(stage0)]
pure fn ne(other: &Implementation) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Implementation) -> bool { !(*self).eq(other) }
}
@ -121,19 +70,9 @@ pub type Section = {
};
impl Section : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Section) -> bool {
self.header == (*other).header && self.body == (*other).body
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Section) -> bool {
(*self).header == (*other).header && (*self).body == (*other).body
}
#[cfg(stage0)]
pure fn ne(other: &Section) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Section) -> bool { !(*self).eq(other) }
}
@ -145,19 +84,9 @@ pub type CrateDoc = {
};
impl CrateDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &CrateDoc) -> bool {
self.topmod == (*other).topmod
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &CrateDoc) -> bool {
(*self).topmod == (*other).topmod
}
#[cfg(stage0)]
pure fn ne(other: &CrateDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &CrateDoc) -> bool { !(*self).eq(other) }
}
@ -174,67 +103,6 @@ pub enum ItemTag {
}
impl ItemTag : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ItemTag) -> bool {
match self {
ModTag(e0a) => {
match (*other) {
ModTag(e0b) => e0a == e0b,
_ => false
}
}
NmodTag(e0a) => {
match (*other) {
NmodTag(e0b) => e0a == e0b,
_ => false
}
}
ConstTag(e0a) => {
match (*other) {
ConstTag(e0b) => e0a == e0b,
_ => false
}
}
FnTag(e0a) => {
match (*other) {
FnTag(e0b) => e0a == e0b,
_ => false
}
}
EnumTag(e0a) => {
match (*other) {
EnumTag(e0b) => e0a == e0b,
_ => false
}
}
TraitTag(e0a) => {
match (*other) {
TraitTag(e0b) => e0a == e0b,
_ => false
}
}
ImplTag(e0a) => {
match (*other) {
ImplTag(e0b) => e0a == e0b,
_ => false
}
}
TyTag(e0a) => {
match (*other) {
TyTag(e0b) => e0a == e0b,
_ => false
}
}
StructTag(e0a) => {
match (*other) {
StructTag(e0b) => e0a == e0b,
_ => false
}
}
}
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ItemTag) -> bool {
match (*self) {
ModTag(e0a) => {
@ -293,10 +161,6 @@ impl ItemTag : cmp::Eq {
}
}
}
#[cfg(stage0)]
pure fn ne(other: &ItemTag) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ItemTag) -> bool { !(*self).eq(other) }
}
@ -312,18 +176,6 @@ pub type ItemDoc = {
};
impl ItemDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ItemDoc) -> bool {
self.id == (*other).id &&
self.name == (*other).name &&
self.path == (*other).path &&
self.brief == (*other).brief &&
self.desc == (*other).desc &&
self.sections == (*other).sections &&
self.reexport == (*other).reexport
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ItemDoc) -> bool {
(*self).id == (*other).id &&
(*self).name == (*other).name &&
@ -333,10 +185,6 @@ impl ItemDoc : cmp::Eq {
(*self).sections == (*other).sections &&
(*self).reexport == (*other).reexport
}
#[cfg(stage0)]
pure fn ne(other: &ItemDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ItemDoc) -> bool { !(*self).eq(other) }
}
@ -346,19 +194,9 @@ pub type SimpleItemDoc = {
};
impl SimpleItemDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &SimpleItemDoc) -> bool {
self.item == (*other).item && self.sig == (*other).sig
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &SimpleItemDoc) -> bool {
(*self).item == (*other).item && (*self).sig == (*other).sig
}
#[cfg(stage0)]
pure fn ne(other: &SimpleItemDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &SimpleItemDoc) -> bool { !(*self).eq(other) }
}
@ -369,23 +207,11 @@ pub type ModDoc_ = {
};
impl ModDoc_ : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ModDoc_) -> bool {
self.item == (*other).item &&
self.items == (*other).items &&
self.index == (*other).index
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ModDoc_) -> bool {
(*self).item == (*other).item &&
(*self).items == (*other).items &&
(*self).index == (*other).index
}
#[cfg(stage0)]
pure fn ne(other: &ModDoc_) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ModDoc_) -> bool { !(*self).eq(other) }
}
@ -394,15 +220,7 @@ pub enum ModDoc {
}
impl ModDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ModDoc) -> bool { *self == *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ModDoc) -> bool { *(*self) == *(*other) }
#[cfg(stage0)]
pure fn ne(other: &ModDoc) -> bool { *self != *(*other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ModDoc) -> bool { *(*self) != *(*other) }
}
@ -413,23 +231,11 @@ pub type NmodDoc = {
};
impl NmodDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &NmodDoc) -> bool {
self.item == (*other).item &&
self.fns == (*other).fns &&
self.index == (*other).index
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &NmodDoc) -> bool {
(*self).item == (*other).item &&
(*self).fns == (*other).fns &&
(*self).index == (*other).index
}
#[cfg(stage0)]
pure fn ne(other: &NmodDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &NmodDoc) -> bool { !(*self).eq(other) }
}
@ -443,19 +249,9 @@ pub type EnumDoc = {
};
impl EnumDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &EnumDoc) -> bool {
self.item == (*other).item && self.variants == (*other).variants
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &EnumDoc) -> bool {
(*self).item == (*other).item && (*self).variants == (*other).variants
}
#[cfg(stage0)]
pure fn ne(other: &EnumDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &EnumDoc) -> bool { !(*self).eq(other) }
}
@ -466,23 +262,11 @@ pub type VariantDoc = {
};
impl VariantDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &VariantDoc) -> bool {
self.name == (*other).name &&
self.desc == (*other).desc &&
self.sig == (*other).sig
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &VariantDoc) -> bool {
(*self).name == (*other).name &&
(*self).desc == (*other).desc &&
(*self).sig == (*other).sig
}
#[cfg(stage0)]
pure fn ne(other: &VariantDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &VariantDoc) -> bool { !(*self).eq(other) }
}
@ -492,19 +276,9 @@ pub type TraitDoc = {
};
impl TraitDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &TraitDoc) -> bool {
self.item == (*other).item && self.methods == (*other).methods
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &TraitDoc) -> bool {
(*self).item == (*other).item && (*self).methods == (*other).methods
}
#[cfg(stage0)]
pure fn ne(other: &TraitDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &TraitDoc) -> bool { !(*self).eq(other) }
}
@ -518,17 +292,6 @@ pub type MethodDoc = {
};
impl MethodDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &MethodDoc) -> bool {
self.name == (*other).name &&
self.brief == (*other).brief &&
self.desc == (*other).desc &&
self.sections == (*other).sections &&
self.sig == (*other).sig &&
self.implementation == (*other).implementation
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &MethodDoc) -> bool {
(*self).name == (*other).name &&
(*self).brief == (*other).brief &&
@ -537,10 +300,6 @@ impl MethodDoc : cmp::Eq {
(*self).sig == (*other).sig &&
(*self).implementation == (*other).implementation
}
#[cfg(stage0)]
pure fn ne(other: &MethodDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &MethodDoc) -> bool { !(*self).eq(other) }
}
@ -552,25 +311,12 @@ pub type ImplDoc = {
};
impl ImplDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &ImplDoc) -> bool {
self.item == (*other).item &&
self.trait_types == (*other).trait_types &&
self.self_ty == (*other).self_ty &&
self.methods == (*other).methods
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &ImplDoc) -> bool {
(*self).item == (*other).item &&
(*self).trait_types == (*other).trait_types &&
(*self).self_ty == (*other).self_ty &&
(*self).methods == (*other).methods
}
#[cfg(stage0)]
pure fn ne(other: &ImplDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &ImplDoc) -> bool { !(*self).eq(other) }
}
@ -583,23 +329,11 @@ pub type StructDoc = {
};
impl StructDoc : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &StructDoc) -> bool {
return self.item == other.item
&& self.fields == other.fields
&& self.sig == other.sig;
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &StructDoc) -> bool {
return (*self).item == other.item
&& (*self).fields == other.fields
&& (*self).sig == other.sig;
}
#[cfg(stage0)]
pure fn ne(other: &StructDoc) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &StructDoc) -> bool { !(*self).eq(other) }
}
@ -608,19 +342,9 @@ pub type Index = {
};
impl Index : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &Index) -> bool {
self.entries == (*other).entries
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &Index) -> bool {
(*self).entries == (*other).entries
}
#[cfg(stage0)]
pure fn ne(other: &Index) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &Index) -> bool { !(*self).eq(other) }
}
@ -642,25 +366,12 @@ pub type IndexEntry = {
};
impl IndexEntry : cmp::Eq {
#[cfg(stage0)]
pure fn eq(other: &IndexEntry) -> bool {
self.kind == (*other).kind &&
self.name == (*other).name &&
self.brief == (*other).brief &&
self.link == (*other).link
}
#[cfg(stage1)]
#[cfg(stage2)]
pure fn eq(&self, other: &IndexEntry) -> bool {
(*self).kind == (*other).kind &&
(*self).name == (*other).name &&
(*self).brief == (*other).brief &&
(*self).link == (*other).link
}
#[cfg(stage0)]
pure fn ne(other: &IndexEntry) -> bool { !self.eq(other) }
#[cfg(stage1)]
#[cfg(stage2)]
pure fn ne(&self, other: &IndexEntry) -> bool { !(*self).eq(other) }
}

View file

@ -52,4 +52,96 @@ mod page_pass;
mod sectionalize_pass;
mod escape_pass;
mod prune_private_pass;
mod util;
mod util;
use doc::ItemUtils;
use doc::Item;
use pass::Pass;
use config::Config;
fn main() {
let args = os::args();
if args.contains(&~"-h") || args.contains(&~"--help") {
config::usage();
return;
}
let config = match config::parse_config(args) {
Ok(config) => config,
Err(err) => {
io::println(fmt!("error: %s", err));
return;
}
};
run(config);
}
/// Runs rustdoc over the given file
fn run(config: Config) {
let source_file = config.input_crate;
// Create an AST service from the source code
do astsrv::from_file(source_file.to_str()) |srv| {
// Just time how long it takes for the AST to become available
do time(~"wait_ast") {
do astsrv::exec(srv) |_ctxt| { }
};
// Extract the initial doc tree from the AST. This contains
// just names and node ids.
let doc = time(~"extract", || {
let default_name = source_file;
extract::from_srv(srv, default_name.to_str())
});
// Refine and publish the document
pass::run_passes(srv, doc, ~[
// Generate type and signature strings
tystr_pass::mk_pass(),
// Record the full paths to various nodes
path_pass::mk_pass(),
// Extract the docs attributes and attach them to doc nodes
attr_pass::mk_pass(),
// Perform various text escaping
escape_pass::mk_pass(),
// Remove things marked doc(hidden)
prune_hidden_pass::mk_pass(),
// Remove things that are private
// XXX enable this after 'export' is removed in favor of 'pub'
// prune_private_pass::mk_pass(),
// Extract brief documentation from the full descriptions
desc_to_brief_pass::mk_pass(),
// Massage the text to remove extra indentation
unindent_pass::mk_pass(),
// Split text into multiple sections according to headers
sectionalize_pass::mk_pass(),
// Trim extra spaces from text
trim_pass::mk_pass(),
// Sort items by name
sort_item_name_pass::mk_pass(),
// Sort items again by kind
sort_item_type_pass::mk_pass(),
// Create indexes appropriate for markdown
markdown_index_pass::mk_pass(config),
// Break the document into pages if required by the
// output format
page_pass::mk_pass(config.output_style),
// Render
markdown_pass::mk_pass(
markdown_writer::make_writer_factory(config)
)
]);
}
}
fn time<T>(what: ~str, f: fn() -> T) -> T {
let start = std::time::precise_time_s();
let rv = f();
let end = std::time::precise_time_s();
info!("time: %3.3f s %s", end - start, what);
move rv
}

View file

@ -1,91 +0,0 @@
use doc::ItemUtils;
use doc::Item;
use pass::Pass;
use config::Config;
fn main() {
let args = os::args();
if args.contains(&~"-h") || args.contains(&~"--help") {
config::usage();
return;
}
let config = match config::parse_config(args) {
Ok(config) => config,
Err(err) => {
io::println(fmt!("error: %s", err));
return;
}
};
run(config);
}
/// Runs rustdoc over the given file
fn run(config: Config) {
let source_file = config.input_crate;
// Create an AST service from the source code
do astsrv::from_file(source_file.to_str()) |srv| {
// Just time how long it takes for the AST to become available
do time(~"wait_ast") {
do astsrv::exec(srv) |_ctxt| { }
};
// Extract the initial doc tree from the AST. This contains
// just names and node ids.
let doc = time(~"extract", || {
let default_name = source_file;
extract::from_srv(srv, default_name.to_str())
});
// Refine and publish the document
pass::run_passes(srv, doc, ~[
// Generate type and signature strings
tystr_pass::mk_pass(),
// Record the full paths to various nodes
path_pass::mk_pass(),
// Extract the docs attributes and attach them to doc nodes
attr_pass::mk_pass(),
// Perform various text escaping
escape_pass::mk_pass(),
// Remove things marked doc(hidden)
prune_hidden_pass::mk_pass(),
// Remove things that are private
// XXX enable this after 'export' is removed in favor of 'pub'
// prune_private_pass::mk_pass(),
// Extract brief documentation from the full descriptions
desc_to_brief_pass::mk_pass(),
// Massage the text to remove extra indentation
unindent_pass::mk_pass(),
// Split text into multiple sections according to headers
sectionalize_pass::mk_pass(),
// Trim extra spaces from text
trim_pass::mk_pass(),
// Sort items by name
sort_item_name_pass::mk_pass(),
// Sort items again by kind
sort_item_type_pass::mk_pass(),
// Create indexes appropriate for markdown
markdown_index_pass::mk_pass(config),
// Break the document into pages if required by the
// output format
page_pass::mk_pass(config.output_style),
// Render
markdown_pass::mk_pass(
markdown_writer::make_writer_factory(config)
)
]);
}
}
fn time<T>(what: ~str, f: fn() -> T) -> T {
let start = std::time::precise_time_s();
let rv = f();
let end = std::time::precise_time_s();
info!("time: %3.3f s %s", end - start, what);
move rv
}