Get rustdoc working with std::par instead of its own par library. Closes #2885.
This commit is contained in:
parent
c8739cb0bc
commit
85e79a3a8a
12 changed files with 29 additions and 60 deletions
|
@ -143,7 +143,7 @@ fn fold_enum(
|
|||
let doc = fold::default_seq_fold_enum(fold, doc);
|
||||
|
||||
{
|
||||
variants: do par::anymap(doc.variants) |variant| {
|
||||
variants: do par::map(doc.variants) |variant| {
|
||||
let desc = do astsrv::exec(srv) |ctxt| {
|
||||
alt check ctxt.ast_map.get(doc_id) {
|
||||
ast_map::node_item(@{
|
||||
|
@ -206,7 +206,7 @@ fn merge_method_attrs(
|
|||
ast_map::node_item(@{
|
||||
node: ast::item_trait(_, methods), _
|
||||
}, _) {
|
||||
par::seqmap(methods, |method| {
|
||||
vec::map(methods, |method| {
|
||||
alt method {
|
||||
ast::required(ty_m) {
|
||||
(*ty_m.ident, attr_parser::parse_desc(ty_m.attrs))
|
||||
|
@ -220,7 +220,7 @@ fn merge_method_attrs(
|
|||
ast_map::node_item(@{
|
||||
node: ast::item_impl(_, _, _, methods), _
|
||||
}, _) {
|
||||
par::seqmap(methods, |method| {
|
||||
vec::map(methods, |method| {
|
||||
(*method.ident, attr_parser::parse_desc(method.attrs))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ fn fold_trait(fold: fold::fold<()>, doc: doc::traitdoc) -> doc::traitdoc {
|
|||
let doc =fold::default_seq_fold_trait(fold, doc);
|
||||
|
||||
{
|
||||
methods: par::anymap(doc.methods, |doc| {
|
||||
methods: par::map(doc.methods, |doc| {
|
||||
brief: extract(doc.desc)
|
||||
with doc
|
||||
})
|
||||
|
@ -52,7 +52,7 @@ fn fold_impl(fold: fold::fold<()>, doc: doc::impldoc) -> doc::impldoc {
|
|||
let doc =fold::default_seq_fold_impl(fold, doc);
|
||||
|
||||
{
|
||||
methods: par::anymap(doc.methods, |doc| {
|
||||
methods: par::map(doc.methods, |doc| {
|
||||
brief: extract(doc.desc)
|
||||
with doc
|
||||
})
|
||||
|
|
|
@ -113,7 +113,7 @@ fn nmoddoc_from_mod(
|
|||
) -> doc::nmoddoc {
|
||||
{
|
||||
item: itemdoc,
|
||||
fns: do par::seqmap(module.items) |item| {
|
||||
fns: do vec::map(module.items) |item| {
|
||||
let itemdoc = mk_itemdoc(item.id, item.ident);
|
||||
alt item.node {
|
||||
ast::foreign_item_fn(_, _) {
|
||||
|
@ -159,7 +159,7 @@ fn enumdoc_from_enum(
|
|||
fn variantdocs_from_variants(
|
||||
variants: ~[ast::variant]
|
||||
) -> ~[doc::variantdoc] {
|
||||
par::seqmap(variants, variantdoc_from_variant)
|
||||
vec::map(variants, variantdoc_from_variant)
|
||||
}
|
||||
|
||||
fn variantdoc_from_variant(variant: ast::variant) -> doc::variantdoc {
|
||||
|
@ -189,7 +189,7 @@ fn traitdoc_from_trait(
|
|||
) -> doc::traitdoc {
|
||||
{
|
||||
item: itemdoc,
|
||||
methods: do par::seqmap(methods) |method| {
|
||||
methods: do vec::map(methods) |method| {
|
||||
alt method {
|
||||
ast::required(ty_m) {
|
||||
{
|
||||
|
@ -236,7 +236,7 @@ fn impldoc_from_impl(
|
|||
item: itemdoc,
|
||||
trait_ty: none,
|
||||
self_ty: none,
|
||||
methods: do par::seqmap(methods) |method| {
|
||||
methods: do vec::map(methods) |method| {
|
||||
{
|
||||
name: *method.ident,
|
||||
brief: none,
|
||||
|
|
|
@ -133,7 +133,7 @@ fn default_par_fold<T:send copy>(ctxt: T) -> fold<T> {
|
|||
|
||||
fn default_seq_fold_doc<T>(fold: fold<T>, doc: doc::doc) -> doc::doc {
|
||||
{
|
||||
pages: do par::seqmap(doc.pages) |page| {
|
||||
pages: do vec::map(doc.pages) |page| {
|
||||
alt page {
|
||||
doc::cratepage(doc) {
|
||||
doc::cratepage(fold.fold_crate(fold, doc))
|
||||
|
@ -169,7 +169,7 @@ fn default_any_fold_mod<T:send copy>(
|
|||
) -> doc::moddoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
items: par::anymap(doc.items, |itemtag, copy fold| {
|
||||
items: par::map(doc.items, |itemtag, copy fold| {
|
||||
fold_itemtag(fold, itemtag)
|
||||
})
|
||||
with doc
|
||||
|
@ -182,7 +182,7 @@ fn default_seq_fold_mod<T>(
|
|||
) -> doc::moddoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
items: par::seqmap(doc.items, |itemtag| {
|
||||
items: vec::map(doc.items, |itemtag| {
|
||||
fold_itemtag(fold, itemtag)
|
||||
})
|
||||
with doc
|
||||
|
@ -195,7 +195,7 @@ fn default_par_fold_mod<T:send copy>(
|
|||
) -> doc::moddoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
items: par::parmap(doc.items, |itemtag, copy fold| {
|
||||
items: par::map(doc.items, |itemtag, copy fold| {
|
||||
fold_itemtag(fold, itemtag)
|
||||
})
|
||||
with doc
|
||||
|
@ -208,7 +208,7 @@ fn default_any_fold_nmod<T:send copy>(
|
|||
) -> doc::nmoddoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
fns: par::anymap(doc.fns, |fndoc, copy fold| {
|
||||
fns: par::map(doc.fns, |fndoc, copy fold| {
|
||||
fold.fold_fn(fold, fndoc)
|
||||
})
|
||||
with doc
|
||||
|
@ -221,7 +221,7 @@ fn default_seq_fold_nmod<T>(
|
|||
) -> doc::nmoddoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
fns: par::seqmap(doc.fns, |fndoc| {
|
||||
fns: vec::map(doc.fns, |fndoc| {
|
||||
fold.fold_fn(fold, fndoc)
|
||||
})
|
||||
with doc
|
||||
|
@ -234,7 +234,7 @@ fn default_par_fold_nmod<T:send copy>(
|
|||
) -> doc::nmoddoc {
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
fns: par::parmap(doc.fns, |fndoc, copy fold| {
|
||||
fns: par::map(doc.fns, |fndoc, copy fold| {
|
||||
fold.fold_fn(fold, fndoc)
|
||||
})
|
||||
with doc
|
||||
|
|
|
@ -55,7 +55,7 @@ fn build_mod_index(
|
|||
config: config::config
|
||||
) -> doc::index {
|
||||
{
|
||||
entries: par::anymap(doc.items, |doc| {
|
||||
entries: par::map(doc.items, |doc| {
|
||||
item_to_entry(doc, config)
|
||||
})
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ fn build_nmod_index(
|
|||
config: config::config
|
||||
) -> doc::index {
|
||||
{
|
||||
entries: par::anymap(doc.fns, |doc| {
|
||||
entries: par::map(doc.fns, |doc| {
|
||||
item_to_entry(doc::fntag(doc), config)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ fn write_markdown(
|
|||
doc: doc::doc,
|
||||
+writer_factory: writer_factory
|
||||
) {
|
||||
do par::anymap(doc.pages) |page| {
|
||||
do par::map(doc.pages) |page| {
|
||||
let ctxt = {
|
||||
w: writer_factory(page)
|
||||
};
|
||||
|
@ -488,7 +488,7 @@ fn write_sig(ctxt: ctxt, sig: option<~str>) {
|
|||
|
||||
fn code_block_indent(s: ~str) -> ~str {
|
||||
let lines = str::lines_any(s);
|
||||
let indented = par::seqmap(lines, |line| #fmt(" %s", line) );
|
||||
let indented = vec::map(lines, |line| #fmt(" %s", line) );
|
||||
str::connect(indented, ~"\n")
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
export anymap, seqmap, parmap;
|
||||
|
||||
fn anymap<T:send, U:send>(v: ~[T], f: fn~(T) -> U) -> ~[U] {
|
||||
parmap(v, f)
|
||||
}
|
||||
|
||||
fn seqmap<T, U>(v: ~[T], f: fn(T) -> U) -> ~[U] {
|
||||
vec::map(v, f)
|
||||
}
|
||||
|
||||
fn parmap<T:send, U:send>(v: ~[T], f: fn~(T) -> U) -> ~[U] unsafe {
|
||||
let futures = do vec::map(v) |elt| {
|
||||
let po = comm::port();
|
||||
let ch = comm::chan(po);
|
||||
let addr = ptr::addr_of(elt);
|
||||
do task::spawn |copy f| {
|
||||
comm::send(ch, f(*addr));
|
||||
}
|
||||
po
|
||||
};
|
||||
do vec::map(futures) |future| {
|
||||
comm::recv(future)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parallel_map() {
|
||||
let i = ~[1, 2, 3, 4];
|
||||
let j = parmap(i, |e| e + 1 );
|
||||
assert j == ~[2, 3, 4, 5];
|
||||
}
|
|
@ -19,6 +19,7 @@ use rustc(vers = "0.3");
|
|||
use syntax(vers = "0.3");
|
||||
|
||||
import core::*;
|
||||
import std::par;
|
||||
|
||||
mod config;
|
||||
mod parse;
|
||||
|
@ -44,7 +45,6 @@ mod sort_pass;
|
|||
mod sort_item_name_pass;
|
||||
mod sort_item_type_pass;
|
||||
mod reexport_pass;
|
||||
mod par;
|
||||
mod page_pass;
|
||||
mod sectionalize_pass;
|
||||
mod escape_pass;
|
||||
|
|
|
@ -34,7 +34,7 @@ fn fold_trait(fold: fold::fold<()>, doc: doc::traitdoc) -> doc::traitdoc {
|
|||
let doc = fold::default_seq_fold_trait(fold, doc);
|
||||
|
||||
{
|
||||
methods: do par::anymap(doc.methods) |method| {
|
||||
methods: do par::map(doc.methods) |method| {
|
||||
let (desc, sections) = sectionalize(method.desc);
|
||||
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ fn fold_impl(fold: fold::fold<()>, doc: doc::impldoc) -> doc::impldoc {
|
|||
let doc = fold::default_seq_fold_impl(fold, doc);
|
||||
|
||||
{
|
||||
methods: do par::anymap(doc.methods) |method| {
|
||||
methods: do par::map(doc.methods) |method| {
|
||||
let (desc, sections) = sectionalize(method.desc);
|
||||
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ fn fold_item(fold: fold::fold<op>, doc: doc::itemdoc) -> doc::itemdoc {
|
|||
}
|
||||
|
||||
fn apply_to_sections(op: op, sections: ~[doc::section]) -> ~[doc::section] {
|
||||
par::anymap(sections, |section, copy op| {
|
||||
par::map(sections, |section, copy op| {
|
||||
header: op(section.header),
|
||||
body: op(section.body)
|
||||
})
|
||||
|
@ -55,7 +55,7 @@ fn fold_enum(fold: fold::fold<op>, doc: doc::enumdoc) -> doc::enumdoc {
|
|||
let doc = fold::default_seq_fold_enum(fold, doc);
|
||||
|
||||
{
|
||||
variants: do par::anymap(doc.variants) |variant, copy fold| {
|
||||
variants: do par::map(doc.variants) |variant, copy fold| {
|
||||
{
|
||||
desc: maybe_apply_op(fold.ctxt, variant.desc)
|
||||
with variant
|
||||
|
@ -75,7 +75,7 @@ fn fold_trait(fold: fold::fold<op>, doc: doc::traitdoc) -> doc::traitdoc {
|
|||
}
|
||||
|
||||
fn apply_to_methods(op: op, docs: ~[doc::methoddoc]) -> ~[doc::methoddoc] {
|
||||
do par::anymap(docs) |doc, copy op| {
|
||||
do par::map(docs) |doc, copy op| {
|
||||
{
|
||||
brief: maybe_apply_op(op, doc.brief),
|
||||
desc: maybe_apply_op(op, doc.desc),
|
||||
|
|
|
@ -106,7 +106,7 @@ fn fold_enum(
|
|||
let srv = fold.ctxt;
|
||||
|
||||
{
|
||||
variants: do par::anymap(doc.variants) |variant| {
|
||||
variants: do par::map(doc.variants) |variant| {
|
||||
let sig = do astsrv::exec(srv) |ctxt| {
|
||||
alt check ctxt.ast_map.get(doc_id) {
|
||||
ast_map::node_item(@{
|
||||
|
@ -152,7 +152,7 @@ fn merge_methods(
|
|||
item_id: doc::ast_id,
|
||||
docs: ~[doc::methoddoc]
|
||||
) -> ~[doc::methoddoc] {
|
||||
do par::anymap(docs) |doc| {
|
||||
do par::map(docs) |doc| {
|
||||
{
|
||||
sig: get_method_sig(srv, item_id, doc.name)
|
||||
with doc
|
||||
|
|
|
@ -62,7 +62,7 @@ fn unindent(s: ~str) -> ~str {
|
|||
|
||||
if vec::is_not_empty(lines) {
|
||||
let unindented = ~[str::trim(vec::head(lines))]
|
||||
+ do par::anymap(vec::tail(lines)) |line| {
|
||||
+ do par::map(vec::tail(lines)) |line| {
|
||||
if str::is_whitespace(line) {
|
||||
line
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue