mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 20:54:13 +00:00
rustdoc: Various bits of modernization
This commit is contained in:
parent
49472ec4c9
commit
1ee94529d9
@ -22,6 +22,7 @@ use core::prelude::*;
|
||||
use parse;
|
||||
use util;
|
||||
|
||||
use core::pipes::stream;
|
||||
use core::oldcomm;
|
||||
use core::vec;
|
||||
use rustc::back::link;
|
||||
@ -62,18 +63,18 @@ impl Srv: Clone {
|
||||
}
|
||||
|
||||
pub fn from_str<T>(source: ~str, owner: SrvOwner<T>) -> T {
|
||||
run(owner, source, parse::from_str_sess)
|
||||
run(owner, copy source, parse::from_str_sess)
|
||||
}
|
||||
|
||||
pub fn from_file<T>(file: ~str, owner: SrvOwner<T>) -> T {
|
||||
run(owner, file, |sess, f| parse::from_file_sess(sess, &Path(f)))
|
||||
run(owner, copy file, |sess, f| parse::from_file_sess(sess, &Path(f)))
|
||||
}
|
||||
|
||||
fn run<T>(owner: SrvOwner<T>, source: ~str, +parse: Parser) -> T {
|
||||
|
||||
let srv_ = Srv({
|
||||
ch: do util::spawn_listener |move parse, po| {
|
||||
act(po, source, parse);
|
||||
ch: do util::spawn_listener |copy source, move parse, po| {
|
||||
act(po, copy source, parse);
|
||||
}
|
||||
});
|
||||
|
||||
@ -87,7 +88,7 @@ fn act(po: oldcomm::Port<Msg>, source: ~str, parse: Parser) {
|
||||
|
||||
let ctxt = build_ctxt(
|
||||
sess,
|
||||
parse(sess, source)
|
||||
parse(sess, copy source)
|
||||
);
|
||||
|
||||
let mut keep_going = true;
|
||||
@ -107,13 +108,12 @@ pub fn exec<T:Owned>(
|
||||
srv: Srv,
|
||||
+f: fn~(ctxt: Ctxt) -> T
|
||||
) -> T {
|
||||
let po = oldcomm::Port();
|
||||
let ch = oldcomm::Chan(&po);
|
||||
let (po, ch) = stream();
|
||||
let msg = HandleRequest(fn~(move f, ctxt: Ctxt) {
|
||||
oldcomm::send(ch, f(ctxt))
|
||||
ch.send(f(ctxt))
|
||||
});
|
||||
oldcomm::send(srv.ch, move msg);
|
||||
oldcomm::recv(po)
|
||||
po.recv()
|
||||
}
|
||||
|
||||
fn build_ctxt(sess: Session,
|
||||
@ -123,7 +123,7 @@ fn build_ctxt(sess: Session,
|
||||
|
||||
let ast = config::strip_unconfigured_items(ast);
|
||||
let ast = syntax::ext::expand::expand_crate(sess.parse_sess,
|
||||
sess.opts.cfg, ast);
|
||||
copy sess.opts.cfg, ast);
|
||||
let ast = front::test::modify_for_testing(sess, ast);
|
||||
let ast_map = ast_map::map_crate(sess.diagnostic(), *ast);
|
||||
|
||||
|
@ -65,17 +65,18 @@ fn fold_crate(
|
||||
let doc = fold::default_seq_fold_crate(fold, doc);
|
||||
|
||||
let attrs = do astsrv::exec(srv) |ctxt| {
|
||||
let attrs = ctxt.ast.node.attrs;
|
||||
let attrs = copy ctxt.ast.node.attrs;
|
||||
attr_parser::parse_crate(attrs)
|
||||
};
|
||||
|
||||
doc::CrateDoc {
|
||||
topmod: doc::ModDoc {
|
||||
item: doc::ItemDoc {
|
||||
name: option::get_or_default(attrs.name, doc.topmod.name()),
|
||||
.. doc.topmod.item
|
||||
name: option::get_or_default(copy attrs.name,
|
||||
doc.topmod.name()),
|
||||
.. copy doc.topmod.item
|
||||
},
|
||||
.. doc.topmod
|
||||
.. copy doc.topmod
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,7 +98,7 @@ fn fold_item(
|
||||
let desc = if doc.id == ast::crate_node_id {
|
||||
// This is the top-level mod, use the crate attributes
|
||||
do astsrv::exec(srv) |ctxt| {
|
||||
attr_parser::parse_desc(ctxt.ast.node.attrs)
|
||||
attr_parser::parse_desc(copy ctxt.ast.node.attrs)
|
||||
}
|
||||
} else {
|
||||
parse_item_attrs(srv, doc.id, attr_parser::parse_desc)
|
||||
@ -115,8 +116,8 @@ fn parse_item_attrs<T:Owned>(
|
||||
+parse_attrs: fn~(+a: ~[ast::attribute]) -> T) -> T {
|
||||
do astsrv::exec(srv) |move parse_attrs, ctxt| {
|
||||
let attrs = match ctxt.ast_map.get(id) {
|
||||
ast_map::node_item(item, _) => item.attrs,
|
||||
ast_map::node_foreign_item(item, _, _) => item.attrs,
|
||||
ast_map::node_item(item, _) => copy item.attrs,
|
||||
ast_map::node_foreign_item(item, _, _) => copy item.attrs,
|
||||
_ => fail ~"parse_item_attrs: not an item"
|
||||
};
|
||||
parse_attrs(attrs)
|
||||
@ -164,18 +165,18 @@ fn fold_enum(
|
||||
|
||||
doc::EnumDoc {
|
||||
variants: do par::map(doc.variants) |variant| {
|
||||
let variant = *variant;
|
||||
let desc = do astsrv::exec(srv) |ctxt| {
|
||||
let variant = copy *variant;
|
||||
let desc = do astsrv::exec(srv) |ctxt, copy variant| {
|
||||
match ctxt.ast_map.get(doc_id) {
|
||||
ast_map::node_item(@ast::item {
|
||||
node: ast::item_enum(enum_definition, _), _
|
||||
node: ast::item_enum(ref enum_definition, _), _
|
||||
}, _) => {
|
||||
let ast_variant = option::get(
|
||||
vec::find(enum_definition.variants, |v| {
|
||||
to_str(v.node.name) == variant.name
|
||||
}));
|
||||
|
||||
attr_parser::parse_desc(ast_variant.node.attrs)
|
||||
attr_parser::parse_desc(copy ast_variant.node.attrs)
|
||||
}
|
||||
_ => fail fmt!("Enum variant %s has id that's not bound \
|
||||
to an enum item", variant.name)
|
||||
@ -212,7 +213,7 @@ fn fold_trait(
|
||||
let doc = fold::default_seq_fold_trait(fold, doc);
|
||||
|
||||
doc::TraitDoc {
|
||||
methods: merge_method_attrs(srv, doc.id(), doc.methods),
|
||||
methods: merge_method_attrs(srv, doc.id(), copy doc.methods),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -227,25 +228,26 @@ fn merge_method_attrs(
|
||||
let attrs: ~[(~str, Option<~str>)] = do astsrv::exec(srv) |ctxt| {
|
||||
match ctxt.ast_map.get(item_id) {
|
||||
ast_map::node_item(@ast::item {
|
||||
node: ast::item_trait(_, _, methods), _
|
||||
node: ast::item_trait(_, _, ref methods), _
|
||||
}, _) => {
|
||||
vec::map(methods, |method| {
|
||||
match *method {
|
||||
vec::map(*methods, |method| {
|
||||
match copy *method {
|
||||
ast::required(ty_m) => {
|
||||
(to_str(ty_m.ident), attr_parser::parse_desc(ty_m.attrs))
|
||||
(to_str(ty_m.ident),
|
||||
attr_parser::parse_desc(copy ty_m.attrs))
|
||||
}
|
||||
ast::provided(m) => {
|
||||
(to_str(m.ident), attr_parser::parse_desc(m.attrs))
|
||||
(to_str(m.ident), attr_parser::parse_desc(copy m.attrs))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
ast_map::node_item(@ast::item {
|
||||
node: ast::item_impl(_, _, _, methods), _
|
||||
node: ast::item_impl(_, _, _, ref methods), _
|
||||
}, _) => {
|
||||
vec::map(methods, |method| {
|
||||
vec::map(*methods, |method| {
|
||||
(to_str(method.ident),
|
||||
attr_parser::parse_desc(method.attrs))
|
||||
attr_parser::parse_desc(copy method.attrs))
|
||||
})
|
||||
}
|
||||
_ => fail ~"unexpected item"
|
||||
@ -258,7 +260,7 @@ fn merge_method_attrs(
|
||||
|
||||
doc::MethodDoc {
|
||||
desc: desc,
|
||||
..*doc
|
||||
.. copy *doc
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -288,7 +290,7 @@ fn fold_impl(
|
||||
let doc = fold::default_seq_fold_impl(fold, doc);
|
||||
|
||||
doc::ImplDoc {
|
||||
methods: merge_method_attrs(srv, doc.id(), doc.methods),
|
||||
methods: merge_method_attrs(srv, doc.id(), copy doc.methods),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -318,7 +320,7 @@ mod test {
|
||||
use extract;
|
||||
|
||||
pub fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
do astsrv::from_str(copy source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
run(srv, doc)
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ pub fn usage() {
|
||||
|
||||
pub fn default_config(input_crate: &Path) -> Config {
|
||||
Config {
|
||||
input_crate: *input_crate,
|
||||
input_crate: copy *input_crate,
|
||||
output_dir: Path("."),
|
||||
output_format: PandocHtml,
|
||||
output_style: DocPerMod,
|
||||
@ -156,21 +156,21 @@ fn config_from_opts(
|
||||
let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
|
||||
let output_dir = output_dir.map(|s| Path(*s));
|
||||
result::Ok(Config {
|
||||
output_dir: output_dir.get_or_default(config.output_dir),
|
||||
output_dir: output_dir.get_or_default(copy config.output_dir),
|
||||
.. config
|
||||
})
|
||||
};
|
||||
let result = do result::chain(result) |config| {
|
||||
let output_format = getopts::opt_maybe_str(
|
||||
matches, opt_output_format());
|
||||
do output_format.map_default(result::Ok(config))
|
||||
do output_format.map_default(result::Ok(copy config))
|
||||
|output_format| {
|
||||
do result::chain(parse_output_format(*output_format))
|
||||
|output_format| {
|
||||
|
||||
result::Ok(Config {
|
||||
output_format: output_format,
|
||||
.. config
|
||||
.. copy config
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -178,13 +178,13 @@ fn config_from_opts(
|
||||
let result = do result::chain(result) |config| {
|
||||
let output_style =
|
||||
getopts::opt_maybe_str(matches, opt_output_style());
|
||||
do output_style.map_default(result::Ok(config))
|
||||
do output_style.map_default(result::Ok(copy config))
|
||||
|output_style| {
|
||||
do result::chain(parse_output_style(*output_style))
|
||||
|output_style| {
|
||||
result::Ok(Config {
|
||||
output_style: output_style,
|
||||
.. config
|
||||
.. copy config
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -197,7 +197,7 @@ fn config_from_opts(
|
||||
do result::chain(pandoc_cmd) |pandoc_cmd| {
|
||||
result::Ok(Config {
|
||||
pandoc_cmd: pandoc_cmd,
|
||||
.. config
|
||||
.. copy config
|
||||
})
|
||||
}
|
||||
};
|
||||
|
@ -63,7 +63,7 @@ fn fold_trait(fold: &fold::Fold<()>, +doc: doc::TraitDoc) -> doc::TraitDoc {
|
||||
doc::TraitDoc {
|
||||
methods: par::map(doc.methods, |doc| doc::MethodDoc {
|
||||
brief: extract(doc.desc),
|
||||
.. *doc
|
||||
.. copy *doc
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
@ -75,7 +75,7 @@ fn fold_impl(fold: &fold::Fold<()>, +doc: doc::ImplDoc) -> doc::ImplDoc {
|
||||
doc::ImplDoc {
|
||||
methods: par::map(doc.methods, |doc| doc::MethodDoc {
|
||||
brief: extract(doc.desc),
|
||||
.. *doc
|
||||
.. copy *doc
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
@ -109,7 +109,7 @@ pub mod test {
|
||||
use extract;
|
||||
|
||||
pub fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
do astsrv::from_str(copy source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
let doc = (attr_pass::mk_pass().f)(srv, doc);
|
||||
run(srv, doc)
|
||||
@ -122,14 +122,14 @@ fn extract(desc: Option<~str>) -> Option<~str> {
|
||||
return None
|
||||
}
|
||||
|
||||
parse_desc(desc.get())
|
||||
parse_desc((copy desc).get())
|
||||
}
|
||||
|
||||
fn parse_desc(desc: ~str) -> Option<~str> {
|
||||
|
||||
const max_brief_len: uint = 120u;
|
||||
|
||||
match first_sentence(desc) {
|
||||
match first_sentence(copy desc) {
|
||||
Some(first_sentence) => {
|
||||
if str::len(first_sentence) <= max_brief_len {
|
||||
Some(first_sentence)
|
||||
@ -142,7 +142,7 @@ fn parse_desc(desc: ~str) -> Option<~str> {
|
||||
}
|
||||
|
||||
fn first_sentence(s: ~str) -> Option<~str> {
|
||||
let paras = paragraphs(s);
|
||||
let paras = paragraphs(copy s);
|
||||
if !paras.is_empty() {
|
||||
let first_para = vec::head(paras);
|
||||
Some(str::replace(first_sentence_(first_para), ~"\n", ~" "))
|
||||
@ -176,7 +176,7 @@ fn first_sentence_(s: ~str) -> ~str {
|
||||
if str::ends_with(s, ~".") {
|
||||
str::slice(s, 0u, str::len(s))
|
||||
} else {
|
||||
s
|
||||
copy s
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
|
||||
whitespace_lines = 0;
|
||||
|
||||
accum = if str::is_empty(accum) {
|
||||
*line
|
||||
copy *line
|
||||
} else {
|
||||
accum + ~"\n" + *line
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ pub struct IndexEntry {
|
||||
impl Doc {
|
||||
fn CrateDoc() -> CrateDoc {
|
||||
option::get(vec::foldl(None, self.pages, |_m, page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
doc::CratePage(doc) => Some(doc),
|
||||
_ => None
|
||||
}
|
||||
@ -185,7 +185,7 @@ impl Doc {
|
||||
}
|
||||
|
||||
fn cratemod() -> ModDoc {
|
||||
self.CrateDoc().topmod
|
||||
copy self.CrateDoc().topmod
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ impl Doc {
|
||||
impl ModDoc {
|
||||
fn mods() -> ~[ModDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match *itemtag {
|
||||
match copy *itemtag {
|
||||
ModTag(ModDoc) => Some(ModDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -202,7 +202,7 @@ impl ModDoc {
|
||||
|
||||
fn nmods() -> ~[NmodDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match *itemtag {
|
||||
match copy *itemtag {
|
||||
NmodTag(nModDoc) => Some(nModDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -211,7 +211,7 @@ impl ModDoc {
|
||||
|
||||
fn fns() -> ~[FnDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match *itemtag {
|
||||
match copy *itemtag {
|
||||
FnTag(FnDoc) => Some(FnDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -220,7 +220,7 @@ impl ModDoc {
|
||||
|
||||
fn consts() -> ~[ConstDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match *itemtag {
|
||||
match copy *itemtag {
|
||||
ConstTag(ConstDoc) => Some(ConstDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -229,7 +229,7 @@ impl ModDoc {
|
||||
|
||||
fn enums() -> ~[EnumDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match *itemtag {
|
||||
match copy *itemtag {
|
||||
EnumTag(EnumDoc) => Some(EnumDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -238,7 +238,7 @@ impl ModDoc {
|
||||
|
||||
fn traits() -> ~[TraitDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match *itemtag {
|
||||
match copy *itemtag {
|
||||
TraitTag(TraitDoc) => Some(TraitDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -247,7 +247,7 @@ impl ModDoc {
|
||||
|
||||
fn impls() -> ~[ImplDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match *itemtag {
|
||||
match copy *itemtag {
|
||||
ImplTag(ImplDoc) => Some(ImplDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -256,7 +256,7 @@ impl ModDoc {
|
||||
|
||||
fn types() -> ~[TyDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match *itemtag {
|
||||
match copy *itemtag {
|
||||
TyTag(TyDoc) => Some(TyDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -265,7 +265,7 @@ impl ModDoc {
|
||||
|
||||
fn structs() -> ~[StructDoc] {
|
||||
do vec::filter_map(self.items) |itemtag| {
|
||||
match *itemtag {
|
||||
match copy *itemtag {
|
||||
StructTag(StructDoc) => Some(StructDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -288,7 +288,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn mods(&self) -> ~[ModDoc] {
|
||||
do vec::filter_map(*self) |page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
ItemPage(ModTag(ModDoc)) => Some(ModDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -297,7 +297,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn nmods(&self) -> ~[NmodDoc] {
|
||||
do vec::filter_map(*self) |page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
ItemPage(NmodTag(nModDoc)) => Some(nModDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -306,7 +306,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn fns(&self) -> ~[FnDoc] {
|
||||
do vec::filter_map(*self) |page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
ItemPage(FnTag(FnDoc)) => Some(FnDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -315,7 +315,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn consts(&self) -> ~[ConstDoc] {
|
||||
do vec::filter_map(*self) |page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
ItemPage(ConstTag(ConstDoc)) => Some(ConstDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -324,7 +324,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn enums(&self) -> ~[EnumDoc] {
|
||||
do vec::filter_map(*self) |page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
ItemPage(EnumTag(EnumDoc)) => Some(EnumDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -333,7 +333,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn traits(&self) -> ~[TraitDoc] {
|
||||
do vec::filter_map(*self) |page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
ItemPage(TraitTag(TraitDoc)) => Some(TraitDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -342,7 +342,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn impls(&self) -> ~[ImplDoc] {
|
||||
do vec::filter_map(*self) |page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
ItemPage(ImplTag(ImplDoc)) => Some(ImplDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -351,7 +351,7 @@ impl ~[Page]: PageUtils {
|
||||
|
||||
fn types(&self) -> ~[TyDoc] {
|
||||
do vec::filter_map(*self) |page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
ItemPage(TyTag(TyDoc)) => Some(TyDoc),
|
||||
_ => None
|
||||
}
|
||||
@ -365,46 +365,46 @@ pub trait Item {
|
||||
|
||||
impl ItemTag: Item {
|
||||
pure fn item(&self) -> ItemDoc {
|
||||
match *self {
|
||||
doc::ModTag(doc) => doc.item,
|
||||
doc::NmodTag(doc) => doc.item,
|
||||
doc::FnTag(doc) => doc.item,
|
||||
doc::ConstTag(doc) => doc.item,
|
||||
doc::EnumTag(doc) => doc.item,
|
||||
doc::TraitTag(doc) => doc.item,
|
||||
doc::ImplTag(doc) => doc.item,
|
||||
doc::TyTag(doc) => doc.item,
|
||||
doc::StructTag(doc) => doc.item
|
||||
match self {
|
||||
&doc::ModTag(ref doc) => copy doc.item,
|
||||
&doc::NmodTag(ref doc) => copy doc.item,
|
||||
&doc::FnTag(ref doc) => copy doc.item,
|
||||
&doc::ConstTag(ref doc) => copy doc.item,
|
||||
&doc::EnumTag(ref doc) => copy doc.item,
|
||||
&doc::TraitTag(ref doc) => copy doc.item,
|
||||
&doc::ImplTag(ref doc) => copy doc.item,
|
||||
&doc::TyTag(ref doc) => copy doc.item,
|
||||
&doc::StructTag(ref doc) => copy doc.item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SimpleItemDoc: Item {
|
||||
pure fn item(&self) -> ItemDoc { self.item }
|
||||
pure fn item(&self) -> ItemDoc { copy self.item }
|
||||
}
|
||||
|
||||
impl ModDoc: Item {
|
||||
pure fn item(&self) -> ItemDoc { self.item }
|
||||
pure fn item(&self) -> ItemDoc { copy self.item }
|
||||
}
|
||||
|
||||
impl NmodDoc: Item {
|
||||
pure fn item(&self) -> ItemDoc { self.item }
|
||||
pure fn item(&self) -> ItemDoc { copy self.item }
|
||||
}
|
||||
|
||||
impl EnumDoc: Item {
|
||||
pure fn item(&self) -> ItemDoc { self.item }
|
||||
pure fn item(&self) -> ItemDoc { copy self.item }
|
||||
}
|
||||
|
||||
impl TraitDoc: Item {
|
||||
pure fn item(&self) -> ItemDoc { self.item }
|
||||
pure fn item(&self) -> ItemDoc { copy self.item }
|
||||
}
|
||||
|
||||
impl ImplDoc: Item {
|
||||
pure fn item(&self) -> ItemDoc { self.item }
|
||||
pure fn item(&self) -> ItemDoc { copy self.item }
|
||||
}
|
||||
|
||||
impl StructDoc: Item {
|
||||
pure fn item(&self) -> ItemDoc { self.item }
|
||||
pure fn item(&self) -> ItemDoc { copy self.item }
|
||||
}
|
||||
|
||||
pub trait ItemUtils {
|
||||
@ -422,22 +422,22 @@ impl<A:Item> A: ItemUtils {
|
||||
}
|
||||
|
||||
pure fn name(&self) -> ~str {
|
||||
self.item().name
|
||||
copy self.item().name
|
||||
}
|
||||
|
||||
pure fn path(&self) -> ~[~str] {
|
||||
self.item().path
|
||||
copy self.item().path
|
||||
}
|
||||
|
||||
pure fn brief(&self) -> Option<~str> {
|
||||
self.item().brief
|
||||
copy self.item().brief
|
||||
}
|
||||
|
||||
pure fn desc(&self) -> Option<~str> {
|
||||
self.item().desc
|
||||
copy self.item().desc
|
||||
}
|
||||
|
||||
pure fn sections(&self) -> ~[Section] {
|
||||
self.item().sections
|
||||
copy self.item().sections
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ macro_rules! interner_key (
|
||||
pub fn to_str(id: ast::ident) -> ~str {
|
||||
let intr = unsafe{ local_data_get(interner_key!()) };
|
||||
|
||||
return *(*intr.get()).get(id);
|
||||
return copy *(*intr.get()).get(id);
|
||||
}
|
||||
|
||||
pub fn interner() -> @syntax::parse::token::ident_interner {
|
||||
@ -49,7 +49,7 @@ pub fn from_srv(
|
||||
//! Use the AST service to create a document tree
|
||||
|
||||
do astsrv::exec(srv) |ctxt| {
|
||||
extract(ctxt.ast, default_name)
|
||||
extract(ctxt.ast, copy default_name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ fn moddoc_from_mod(
|
||||
item: itemdoc,
|
||||
items: do vec::filter_map(module_.items) |item| {
|
||||
let ItemDoc = mk_itemdoc(item.id, to_str(item.ident));
|
||||
match item.node {
|
||||
match copy item.node {
|
||||
ast::item_mod(m) => {
|
||||
Some(doc::ModTag(
|
||||
moddoc_from_mod(ItemDoc, m)
|
||||
@ -117,7 +117,7 @@ fn moddoc_from_mod(
|
||||
}
|
||||
ast::item_enum(enum_definition, _) => {
|
||||
Some(doc::EnumTag(
|
||||
enumdoc_from_enum(ItemDoc, enum_definition.variants)
|
||||
enumdoc_from_enum(ItemDoc, copy enum_definition.variants)
|
||||
))
|
||||
}
|
||||
ast::item_trait(_, _, methods) => {
|
||||
@ -233,7 +233,7 @@ fn traitdoc_from_trait(
|
||||
doc::TraitDoc {
|
||||
item: itemdoc,
|
||||
methods: do vec::map(methods) |method| {
|
||||
match *method {
|
||||
match copy *method {
|
||||
ast::required(ty_m) => {
|
||||
doc::MethodDoc {
|
||||
name: to_str(ty_m.ident),
|
||||
@ -398,7 +398,7 @@ mod test {
|
||||
pub fn extract_fns() {
|
||||
let doc = mk_doc(
|
||||
~"fn a() { } \
|
||||
mod b {
|
||||
mod b { fn c() {
|
||||
} }");
|
||||
assert doc.cratemod().fns()[0].name() == ~"a";
|
||||
assert doc.cratemod().mods()[0].fns()[0].name() == ~"c";
|
||||
|
@ -160,7 +160,7 @@ pub fn default_par_fold<T:Owned Clone>(+ctxt: T) -> Fold<T> {
|
||||
pub fn default_seq_fold_doc<T>(fold: &Fold<T>, +doc: doc::Doc) -> doc::Doc {
|
||||
doc::Doc {
|
||||
pages: do vec::map(doc.pages) |page| {
|
||||
match *page {
|
||||
match copy *page {
|
||||
doc::CratePage(doc) => {
|
||||
doc::CratePage((fold.fold_crate)(fold, doc))
|
||||
}
|
||||
@ -178,7 +178,7 @@ pub fn default_seq_fold_crate<T>(
|
||||
+doc: doc::CrateDoc
|
||||
) -> doc::CrateDoc {
|
||||
doc::CrateDoc {
|
||||
topmod: (fold.fold_mod)(fold, doc.topmod)
|
||||
topmod: (fold.fold_mod)(fold, copy doc.topmod)
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,9 +195,9 @@ pub fn default_any_fold_mod<T:Owned Clone>(
|
||||
) -> doc::ModDoc {
|
||||
let fold_copy = fold.clone();
|
||||
doc::ModDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
items: par::map(doc.items, |ItemTag, move fold_copy| {
|
||||
fold_ItemTag(&fold_copy, *ItemTag)
|
||||
fold_ItemTag(&fold_copy, copy *ItemTag)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
@ -208,9 +208,9 @@ pub fn default_seq_fold_mod<T>(
|
||||
+doc: doc::ModDoc
|
||||
) -> doc::ModDoc {
|
||||
doc::ModDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
items: vec::map(doc.items, |ItemTag| {
|
||||
fold_ItemTag(fold, *ItemTag)
|
||||
fold_ItemTag(fold, copy *ItemTag)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
@ -222,9 +222,9 @@ pub fn default_par_fold_mod<T:Owned Clone>(
|
||||
) -> doc::ModDoc {
|
||||
let fold_copy = fold.clone();
|
||||
doc::ModDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
items: par::map(doc.items, |ItemTag, move fold_copy| {
|
||||
fold_ItemTag(&fold_copy, *ItemTag)
|
||||
fold_ItemTag(&fold_copy, copy *ItemTag)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
@ -236,9 +236,9 @@ pub fn default_any_fold_nmod<T:Owned Clone>(
|
||||
) -> doc::NmodDoc {
|
||||
let fold_copy = fold.clone();
|
||||
doc::NmodDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
fns: par::map(doc.fns, |FnDoc, move fold_copy| {
|
||||
(fold_copy.fold_fn)(&fold_copy, *FnDoc)
|
||||
(fold_copy.fold_fn)(&fold_copy, copy *FnDoc)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
@ -249,9 +249,9 @@ pub fn default_seq_fold_nmod<T>(
|
||||
+doc: doc::NmodDoc
|
||||
) -> doc::NmodDoc {
|
||||
doc::NmodDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
fns: vec::map(doc.fns, |FnDoc| {
|
||||
(fold.fold_fn)(fold, *FnDoc)
|
||||
(fold.fold_fn)(fold, copy *FnDoc)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
@ -263,9 +263,9 @@ pub fn default_par_fold_nmod<T:Owned Clone>(
|
||||
) -> doc::NmodDoc {
|
||||
let fold_copy = fold.clone();
|
||||
doc::NmodDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
fns: par::map(doc.fns, |FnDoc, move fold_copy| {
|
||||
(fold_copy.fold_fn)(&fold_copy, *FnDoc)
|
||||
(fold_copy.fold_fn)(&fold_copy, copy *FnDoc)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
@ -308,7 +308,7 @@ pub fn default_seq_fold_fn<T>(
|
||||
+doc: doc::FnDoc
|
||||
) -> doc::FnDoc {
|
||||
doc::SimpleItemDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -318,7 +318,7 @@ pub fn default_seq_fold_const<T>(
|
||||
+doc: doc::ConstDoc
|
||||
) -> doc::ConstDoc {
|
||||
doc::SimpleItemDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -328,7 +328,7 @@ pub fn default_seq_fold_enum<T>(
|
||||
+doc: doc::EnumDoc
|
||||
) -> doc::EnumDoc {
|
||||
doc::EnumDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -338,7 +338,7 @@ pub fn default_seq_fold_trait<T>(
|
||||
+doc: doc::TraitDoc
|
||||
) -> doc::TraitDoc {
|
||||
doc::TraitDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -348,7 +348,7 @@ pub fn default_seq_fold_impl<T>(
|
||||
+doc: doc::ImplDoc
|
||||
) -> doc::ImplDoc {
|
||||
doc::ImplDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -358,7 +358,7 @@ pub fn default_seq_fold_type<T>(
|
||||
+doc: doc::TyDoc
|
||||
) -> doc::TyDoc {
|
||||
doc::SimpleItemDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -368,7 +368,7 @@ pub fn default_seq_fold_struct<T>(
|
||||
+doc: doc::StructDoc
|
||||
) -> doc::StructDoc {
|
||||
doc::StructDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -379,7 +379,7 @@ fn default_fold_should_produce_same_doc() {
|
||||
let ast = parse::from_str(source);
|
||||
let doc = extract::extract(ast, ~"");
|
||||
let fld = default_seq_fold(());
|
||||
let folded = (fld.fold_doc)(&fld, doc);
|
||||
let folded = (fld.fold_doc)(&fld, copy doc);
|
||||
assert doc == folded;
|
||||
}
|
||||
|
||||
@ -389,7 +389,7 @@ fn default_fold_should_produce_same_consts() {
|
||||
let ast = parse::from_str(source);
|
||||
let doc = extract::extract(ast, ~"");
|
||||
let fld = default_seq_fold(());
|
||||
let folded = (fld.fold_doc)(&fld, doc);
|
||||
let folded = (fld.fold_doc)(&fld, copy doc);
|
||||
assert doc == folded;
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ fn default_fold_should_produce_same_enums() {
|
||||
let ast = parse::from_str(source);
|
||||
let doc = extract::extract(ast, ~"");
|
||||
let fld = default_seq_fold(());
|
||||
let folded = (fld.fold_doc)(&fld, doc);
|
||||
let folded = (fld.fold_doc)(&fld, copy doc);
|
||||
assert doc == folded;
|
||||
}
|
||||
|
||||
@ -409,6 +409,6 @@ fn default_parallel_fold_should_produce_same_doc() {
|
||||
let ast = parse::from_str(source);
|
||||
let doc = extract::extract(ast, ~"");
|
||||
let fld = default_par_fold(());
|
||||
let folded = (fld.fold_doc)(&fld, doc);
|
||||
let folded = (fld.fold_doc)(&fld, copy doc);
|
||||
assert doc == folded;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ pub fn mk_pass(+config: config::Config) -> Pass {
|
||||
Pass {
|
||||
name: ~"markdown_index",
|
||||
f: fn~(srv: astsrv::Srv, +doc: doc::Doc) -> doc::Doc {
|
||||
run(srv, doc, config)
|
||||
run(srv, doc, copy config)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -55,7 +55,7 @@ fn fold_mod(
|
||||
let doc = fold::default_any_fold_mod(fold, doc);
|
||||
|
||||
doc::ModDoc {
|
||||
index: Some(build_mod_index(doc, fold.ctxt)),
|
||||
index: Some(build_mod_index(copy doc, copy fold.ctxt)),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -68,7 +68,7 @@ fn fold_nmod(
|
||||
let doc = fold::default_any_fold_nmod(fold, doc);
|
||||
|
||||
doc::NmodDoc {
|
||||
index: Some(build_nmod_index(doc, fold.ctxt)),
|
||||
index: Some(build_nmod_index(copy doc, copy fold.ctxt)),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -79,7 +79,7 @@ fn build_mod_index(
|
||||
) -> doc::Index {
|
||||
doc::Index {
|
||||
entries: par::map(doc.items, |doc| {
|
||||
item_to_entry(*doc, config)
|
||||
item_to_entry(copy *doc, copy config)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -90,7 +90,7 @@ fn build_nmod_index(
|
||||
) -> doc::Index {
|
||||
doc::Index {
|
||||
entries: par::map(doc.fns, |doc| {
|
||||
item_to_entry(doc::FnTag(*doc), config)
|
||||
item_to_entry(doc::FnTag(copy *doc), copy config)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -110,8 +110,8 @@ fn item_to_entry(
|
||||
};
|
||||
|
||||
doc::IndexEntry {
|
||||
kind: markdown_pass::header_kind(doc),
|
||||
name: markdown_pass::header_name(doc),
|
||||
kind: markdown_pass::header_kind(copy doc),
|
||||
name: markdown_pass::header_name(copy doc),
|
||||
brief: doc.brief(),
|
||||
link: link
|
||||
}
|
||||
@ -180,13 +180,13 @@ fn should_index_mod_contents() {
|
||||
config::DocPerCrate,
|
||||
~"mod a { } fn b() { }"
|
||||
);
|
||||
assert doc.cratemod().index.get().entries[0] == doc::IndexEntry {
|
||||
assert (&doc.cratemod().index).get().entries[0] == doc::IndexEntry {
|
||||
kind: ~"Module",
|
||||
name: ~"a",
|
||||
brief: None,
|
||||
link: ~"#module-a"
|
||||
};
|
||||
assert doc.cratemod().index.get().entries[1] == doc::IndexEntry {
|
||||
assert (&doc.cratemod().index).get().entries[1] == doc::IndexEntry {
|
||||
kind: ~"Function",
|
||||
name: ~"b",
|
||||
brief: None,
|
||||
@ -200,13 +200,13 @@ fn should_index_mod_contents_multi_page() {
|
||||
config::DocPerMod,
|
||||
~"mod a { } fn b() { }"
|
||||
);
|
||||
assert doc.cratemod().index.get().entries[0] == doc::IndexEntry {
|
||||
assert (&doc.cratemod().index).get().entries[0] == doc::IndexEntry {
|
||||
kind: ~"Module",
|
||||
name: ~"a",
|
||||
brief: None,
|
||||
link: ~"a.html"
|
||||
};
|
||||
assert doc.cratemod().index.get().entries[1] == doc::IndexEntry {
|
||||
assert (&doc.cratemod().index).get().entries[1] == doc::IndexEntry {
|
||||
kind: ~"Function",
|
||||
name: ~"b",
|
||||
brief: None,
|
||||
@ -220,7 +220,7 @@ fn should_index_foreign_mod_pages() {
|
||||
config::DocPerMod,
|
||||
~"extern mod a { }"
|
||||
);
|
||||
assert doc.cratemod().index.get().entries[0] == doc::IndexEntry {
|
||||
assert (&doc.cratemod().index).get().entries[0] == doc::IndexEntry {
|
||||
kind: ~"Foreign module",
|
||||
name: ~"a",
|
||||
brief: None,
|
||||
@ -234,7 +234,7 @@ fn should_add_brief_desc_to_index() {
|
||||
config::DocPerMod,
|
||||
~"#[doc = \"test\"] mod a { }"
|
||||
);
|
||||
assert doc.cratemod().index.get().entries[0].brief
|
||||
assert (&doc.cratemod().index).get().entries[0].brief
|
||||
== Some(~"test");
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ fn should_index_foreign_mod_contents() {
|
||||
config::DocPerCrate,
|
||||
~"extern mod a { fn b(); }"
|
||||
);
|
||||
assert doc.cratemod().nmods()[0].index.get().entries[0]
|
||||
assert (&doc.cratemod().nmods()[0].index).get().entries[0]
|
||||
== doc::IndexEntry {
|
||||
kind: ~"Function",
|
||||
name: ~"b",
|
||||
|
@ -76,7 +76,7 @@ fn run(
|
||||
// makes the headers come out nested correctly.
|
||||
let sorted_doc = (sort_pass::mk_pass(
|
||||
~"mods last", mods_last
|
||||
).f)(srv, doc);
|
||||
).f)(srv, copy doc);
|
||||
|
||||
write_markdown(sorted_doc, move writer_factory);
|
||||
|
||||
@ -123,15 +123,15 @@ pub fn write_markdown(
|
||||
// (See #2484, which is closed.)
|
||||
do doc.pages.map |page| {
|
||||
let ctxt = {
|
||||
w: writer_factory(*page)
|
||||
w: writer_factory(copy *page)
|
||||
};
|
||||
write_page(&ctxt, page)
|
||||
};
|
||||
}
|
||||
|
||||
fn write_page(ctxt: &Ctxt, page: &doc::Page) {
|
||||
write_title(ctxt, *page);
|
||||
match *page {
|
||||
write_title(ctxt, copy *page);
|
||||
match copy *page {
|
||||
doc::CratePage(doc) => {
|
||||
write_crate(ctxt, doc);
|
||||
}
|
||||
@ -167,7 +167,7 @@ fn write_title(ctxt: &Ctxt, +page: doc::Page) {
|
||||
fn make_title(+page: doc::Page) -> ~str {
|
||||
let item = match page {
|
||||
doc::CratePage(CrateDoc) => {
|
||||
doc::ModTag(CrateDoc.topmod)
|
||||
doc::ModTag(copy CrateDoc.topmod)
|
||||
}
|
||||
doc::ItemPage(ItemTag) => {
|
||||
ItemTag
|
||||
@ -254,16 +254,16 @@ pub fn header_kind(+doc: doc::ItemTag) -> ~str {
|
||||
|
||||
pub fn header_name(+doc: doc::ItemTag) -> ~str {
|
||||
let fullpath = str::connect(doc.path() + ~[doc.name()], ~"::");
|
||||
match doc {
|
||||
doc::ModTag(_) if doc.id() != syntax::ast::crate_node_id => {
|
||||
match &doc {
|
||||
&doc::ModTag(_) if doc.id() != syntax::ast::crate_node_id => {
|
||||
fullpath
|
||||
}
|
||||
doc::NmodTag(_) => {
|
||||
&doc::NmodTag(_) => {
|
||||
fullpath
|
||||
}
|
||||
doc::ImplTag(doc) => {
|
||||
&doc::ImplTag(ref doc) => {
|
||||
assert doc.self_ty.is_some();
|
||||
let self_ty = doc.self_ty.get();
|
||||
let self_ty = (&doc.self_ty).get();
|
||||
let mut trait_part = ~"";
|
||||
for doc.trait_types.eachi |i, trait_type| {
|
||||
if i == 0 {
|
||||
@ -282,14 +282,14 @@ pub fn header_name(+doc: doc::ItemTag) -> ~str {
|
||||
}
|
||||
|
||||
pub fn header_text(+doc: doc::ItemTag) -> ~str {
|
||||
match doc {
|
||||
doc::ImplTag(ImplDoc) => {
|
||||
let header_kind = header_kind(doc);
|
||||
match &doc {
|
||||
&doc::ImplTag(ref ImplDoc) => {
|
||||
let header_kind = header_kind(copy doc);
|
||||
let desc = if ImplDoc.trait_types.is_empty() {
|
||||
fmt!("for `%s`", ImplDoc.self_ty.get())
|
||||
fmt!("for `%s`", (&ImplDoc.self_ty).get())
|
||||
} else {
|
||||
fmt!("of `%s` for `%s`", ImplDoc.trait_types[0],
|
||||
ImplDoc.self_ty.get())
|
||||
(&ImplDoc.self_ty).get())
|
||||
};
|
||||
fmt!("%s %s", header_kind, desc)
|
||||
}
|
||||
@ -307,7 +307,7 @@ fn write_crate(
|
||||
ctxt: &Ctxt,
|
||||
+doc: doc::CrateDoc
|
||||
) {
|
||||
write_top_module(ctxt, doc.topmod);
|
||||
write_top_module(ctxt, copy doc.topmod);
|
||||
}
|
||||
|
||||
fn write_top_module(
|
||||
@ -354,13 +354,13 @@ fn write_desc(
|
||||
|
||||
fn write_sections(ctxt: &Ctxt, sections: &[doc::Section]) {
|
||||
for vec::each(sections) |section| {
|
||||
write_section(ctxt, *section);
|
||||
write_section(ctxt, copy *section);
|
||||
}
|
||||
}
|
||||
|
||||
fn write_section(ctxt: &Ctxt, +section: doc::Section) {
|
||||
write_header_(ctxt, H4, section.header);
|
||||
ctxt.w.write_line(section.body);
|
||||
write_header_(ctxt, H4, copy section.header);
|
||||
ctxt.w.write_line(copy section.body);
|
||||
ctxt.w.write_line(~"");
|
||||
}
|
||||
|
||||
@ -381,11 +381,11 @@ fn write_mod_contents(
|
||||
) {
|
||||
write_oldcommon(ctxt, doc.desc(), doc.sections());
|
||||
if doc.index.is_some() {
|
||||
write_index(ctxt, doc.index.get());
|
||||
write_index(ctxt, (&doc.index).get());
|
||||
}
|
||||
|
||||
for doc.items.each |itemTag| {
|
||||
write_item(ctxt, *itemTag);
|
||||
write_item(ctxt, copy *itemTag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ fn write_item_no_header(ctxt: &Ctxt, +doc: doc::ItemTag) {
|
||||
|
||||
fn write_item_(ctxt: &Ctxt, +doc: doc::ItemTag, write_header: bool) {
|
||||
if write_header {
|
||||
write_item_header(ctxt, doc);
|
||||
write_item_header(ctxt, copy doc);
|
||||
}
|
||||
|
||||
match doc {
|
||||
@ -439,10 +439,10 @@ fn write_index(ctxt: &Ctxt, +index: doc::Index) {
|
||||
|
||||
for index.entries.each |entry| {
|
||||
let header = header_text_(entry.kind, entry.name);
|
||||
let id = entry.link;
|
||||
let id = copy entry.link;
|
||||
if entry.brief.is_some() {
|
||||
ctxt.w.write_line(fmt!("* [%s](%s) - %s",
|
||||
header, id, entry.brief.get()));
|
||||
header, id, (&entry.brief).get()));
|
||||
} else {
|
||||
ctxt.w.write_line(fmt!("* [%s](%s)", header, id));
|
||||
}
|
||||
@ -484,12 +484,12 @@ fn should_write_index_for_foreign_mods() {
|
||||
fn write_nmod(ctxt: &Ctxt, +doc: doc::NmodDoc) {
|
||||
write_oldcommon(ctxt, doc.desc(), doc.sections());
|
||||
if doc.index.is_some() {
|
||||
write_index(ctxt, doc.index.get());
|
||||
write_index(ctxt, (&doc.index).get());
|
||||
}
|
||||
|
||||
for doc.fns.each |FnDoc| {
|
||||
write_item_header(ctxt, doc::FnTag(*FnDoc));
|
||||
write_fn(ctxt, *FnDoc);
|
||||
write_item_header(ctxt, doc::FnTag(copy *FnDoc));
|
||||
write_fn(ctxt, copy *FnDoc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -520,7 +520,7 @@ fn write_fn(
|
||||
) {
|
||||
write_fnlike(
|
||||
ctxt,
|
||||
doc.sig,
|
||||
copy doc.sig,
|
||||
doc.desc(),
|
||||
doc.sections()
|
||||
);
|
||||
@ -579,7 +579,7 @@ fn should_correctly_indent_fn_signature() {
|
||||
topmod: doc::ModDoc{
|
||||
items: ~[doc::FnTag(doc::SimpleItemDoc{
|
||||
sig: Some(~"line 1\nline 2"),
|
||||
.. doc.cratemod().fns()[0]
|
||||
.. copy doc.cratemod().fns()[0]
|
||||
})],
|
||||
.. doc.cratemod()
|
||||
},
|
||||
@ -601,7 +601,7 @@ fn write_const(
|
||||
ctxt: &Ctxt,
|
||||
+doc: doc::ConstDoc
|
||||
) {
|
||||
write_sig(ctxt, doc.sig);
|
||||
write_sig(ctxt, copy doc.sig);
|
||||
write_oldcommon(ctxt, doc.desc(), doc.sections());
|
||||
}
|
||||
|
||||
@ -651,7 +651,7 @@ fn write_variants(
|
||||
write_header_(ctxt, H4, ~"Variants");
|
||||
|
||||
for vec::each(docs) |variant| {
|
||||
write_variant(ctxt, *variant);
|
||||
write_variant(ctxt, copy *variant);
|
||||
}
|
||||
|
||||
ctxt.w.write_line(~"");
|
||||
@ -659,8 +659,8 @@ fn write_variants(
|
||||
|
||||
fn write_variant(ctxt: &Ctxt, +doc: doc::VariantDoc) {
|
||||
assert doc.sig.is_some();
|
||||
let sig = doc.sig.get();
|
||||
match doc.desc {
|
||||
let sig = (&doc.sig).get();
|
||||
match copy doc.desc {
|
||||
Some(desc) => {
|
||||
ctxt.w.write_line(fmt!("* `%s` - %s", sig, desc));
|
||||
}
|
||||
@ -710,7 +710,7 @@ fn write_trait(ctxt: &Ctxt, +doc: doc::TraitDoc) {
|
||||
|
||||
fn write_methods(ctxt: &Ctxt, docs: &[doc::MethodDoc]) {
|
||||
for vec::each(docs) |doc| {
|
||||
write_method(ctxt, *doc);
|
||||
write_method(ctxt, copy *doc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -718,8 +718,8 @@ fn write_method(ctxt: &Ctxt, +doc: doc::MethodDoc) {
|
||||
write_header_(ctxt, H3, header_text_(~"Method", doc.name));
|
||||
write_fnlike(
|
||||
ctxt,
|
||||
doc.sig,
|
||||
doc.desc,
|
||||
copy doc.sig,
|
||||
copy doc.desc,
|
||||
doc.sections
|
||||
);
|
||||
}
|
||||
@ -793,7 +793,7 @@ fn write_type(
|
||||
ctxt: &Ctxt,
|
||||
+doc: doc::TyDoc
|
||||
) {
|
||||
write_sig(ctxt, doc.sig);
|
||||
write_sig(ctxt, copy doc.sig);
|
||||
write_oldcommon(ctxt, doc.desc(), doc.sections());
|
||||
}
|
||||
|
||||
@ -820,7 +820,7 @@ fn write_struct(
|
||||
ctxt: &Ctxt,
|
||||
+doc: doc::StructDoc
|
||||
) {
|
||||
write_sig(ctxt, doc.sig);
|
||||
write_sig(ctxt, copy doc.sig);
|
||||
write_oldcommon(ctxt, doc.desc(), doc.sections());
|
||||
}
|
||||
|
||||
|
@ -70,13 +70,13 @@ pub fn make_writer_factory(+config: config::Config) -> WriterFactory {
|
||||
|
||||
fn markdown_writer_factory(+config: config::Config) -> WriterFactory {
|
||||
fn~(+page: doc::Page) -> Writer {
|
||||
markdown_writer(config, page)
|
||||
markdown_writer(copy config, page)
|
||||
}
|
||||
}
|
||||
|
||||
fn pandoc_writer_factory(+config: config::Config) -> WriterFactory {
|
||||
fn~(+page: doc::Page) -> Writer {
|
||||
pandoc_writer(config, page)
|
||||
pandoc_writer(copy config, page)
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ fn pandoc_writer(
|
||||
+page: doc::Page
|
||||
) -> Writer {
|
||||
assert config.pandoc_cmd.is_some();
|
||||
let pandoc_cmd = config.pandoc_cmd.get();
|
||||
let pandoc_cmd = (&config.pandoc_cmd).get();
|
||||
let filename = make_local_filename(config, page);
|
||||
|
||||
let pandoc_args = ~[
|
||||
@ -195,7 +195,7 @@ fn make_local_filename(
|
||||
+config: config::Config,
|
||||
+page: doc::Page
|
||||
) -> Path {
|
||||
let filename = make_filename(config, page);
|
||||
let filename = make_filename(copy config, page);
|
||||
config.output_dir.push_rel(&filename)
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ fn should_name_mod_file_names_by_path() {
|
||||
.. config::default_config(&Path("input/test.rc"))
|
||||
};
|
||||
let doc = test::mk_doc(~"", ~"mod a { mod b { } }");
|
||||
let modb = doc.cratemod().mods()[0].mods()[0];
|
||||
let modb = copy doc.cratemod().mods()[0].mods()[0];
|
||||
let page = doc::ItemPage(doc::ModTag(modb));
|
||||
let filename = make_local_filename(config, page);
|
||||
assert filename == Path("output/dir/a_b.html");
|
||||
@ -279,7 +279,7 @@ mod test {
|
||||
|
||||
pub fn mk_doc(+name: ~str, +source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
let doc = extract::from_srv(srv, name);
|
||||
let doc = extract::from_srv(srv, copy name);
|
||||
let doc = (path_pass::mk_pass().f)(srv, doc);
|
||||
doc
|
||||
}
|
||||
@ -307,7 +307,7 @@ pub fn future_writer_factory(
|
||||
let (writer, future) = future_writer();
|
||||
writer_ch.send(move writer);
|
||||
let s = future.get();
|
||||
oldcomm::send(markdown_ch, (page, s));
|
||||
oldcomm::send(markdown_ch, (copy page, s));
|
||||
}
|
||||
writer_po.recv()
|
||||
};
|
||||
|
@ -88,7 +88,7 @@ fn find_pages(doc: doc::Doc, page_chan: PageChan) {
|
||||
fold_nmod: fold_nmod,
|
||||
.. fold::default_any_fold(NominalOp { op: page_chan })
|
||||
};
|
||||
(fold.fold_doc)(&fold, doc);
|
||||
(fold.fold_doc)(&fold, copy doc);
|
||||
|
||||
oldcomm::send(page_chan, None);
|
||||
}
|
||||
@ -102,7 +102,7 @@ fn fold_crate(
|
||||
|
||||
let page = doc::CratePage(doc::CrateDoc {
|
||||
topmod: strip_mod(doc.topmod),
|
||||
.. doc
|
||||
.. copy doc
|
||||
});
|
||||
|
||||
oldcomm::send(fold.ctxt.op, Some(page));
|
||||
@ -136,7 +136,7 @@ fn strip_mod(doc: doc::ModDoc) -> doc::ModDoc {
|
||||
_ => true
|
||||
}
|
||||
},
|
||||
.. doc
|
||||
.. copy doc
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ fn fold_nmod(
|
||||
+doc: doc::NmodDoc
|
||||
) -> doc::NmodDoc {
|
||||
let doc = fold::default_seq_fold_nmod(fold, doc);
|
||||
let page = doc::ItemPage(doc::NmodTag(doc));
|
||||
let page = doc::ItemPage(doc::NmodTag(copy doc));
|
||||
oldcomm::send(fold.ctxt.op, Some(page));
|
||||
return doc;
|
||||
}
|
||||
@ -195,13 +195,13 @@ mod test {
|
||||
output_style: config::OutputStyle,
|
||||
source: ~str
|
||||
) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
do astsrv::from_str(copy source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
run(srv, doc, output_style)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mk_doc(source: ~str) -> doc::Doc {
|
||||
mk_doc_(config::DocPerMod, source)
|
||||
mk_doc_(config::DocPerMod, copy source)
|
||||
}
|
||||
}
|
||||
|
@ -32,12 +32,12 @@ pub fn from_str(+source: ~str) -> @ast::crate {
|
||||
|
||||
pub fn from_file_sess(sess: session::Session, file: &Path) -> @ast::crate {
|
||||
parse::parse_crate_from_file(
|
||||
file, cfg(sess, file_input(*file)), sess.parse_sess)
|
||||
file, cfg(sess, file_input(copy *file)), sess.parse_sess)
|
||||
}
|
||||
|
||||
pub fn from_str_sess(sess: session::Session, +source: ~str) -> @ast::crate {
|
||||
parse::parse_crate_from_source_str(
|
||||
~"-", @source, cfg(sess, str_input(source)), sess.parse_sess)
|
||||
~"-", @copy source, cfg(sess, str_input(source)), sess.parse_sess)
|
||||
}
|
||||
|
||||
fn cfg(sess: session::Session, +input: driver::input) -> ast::crate_cfg {
|
||||
|
@ -32,9 +32,8 @@ pub fn run_passes(
|
||||
do vec::foldl(doc, passes) |doc, pass| {
|
||||
log(debug, fmt!("pass #%d", passno));
|
||||
passno += 1;
|
||||
log(debug, doc);
|
||||
do time(pass.name) {
|
||||
(pass.f)(srv, doc)
|
||||
do time(copy pass.name) {
|
||||
(pass.f)(srv, copy doc)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,7 +50,7 @@ fn test_run_passes() {
|
||||
topmod: doc::ModDoc{
|
||||
item: doc::ItemDoc {
|
||||
name: doc.cratemod().name() + ~"two",
|
||||
.. doc.cratemod().item
|
||||
.. copy doc.cratemod().item
|
||||
},
|
||||
items: ~[],
|
||||
index: None
|
||||
@ -70,7 +69,7 @@ fn test_run_passes() {
|
||||
topmod: doc::ModDoc{
|
||||
item: doc::ItemDoc {
|
||||
name: doc.cratemod().name() + ~"three",
|
||||
.. doc.cratemod().item
|
||||
.. copy doc.cratemod().item
|
||||
},
|
||||
items: ~[],
|
||||
index: None
|
||||
|
@ -55,7 +55,7 @@ fn run(srv: astsrv::Srv, +doc: doc::Doc) -> doc::Doc {
|
||||
|
||||
fn fold_item(fold: &fold::Fold<Ctxt>, +doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||
doc::ItemDoc {
|
||||
path: fold.ctxt.path,
|
||||
path: copy fold.ctxt.path,
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -69,7 +69,7 @@ fn fold_mod(fold: &fold::Fold<Ctxt>, +doc: doc::ModDoc) -> doc::ModDoc {
|
||||
if !is_topmod { fold.ctxt.path.pop(); }
|
||||
|
||||
doc::ModDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@ fn fold_nmod(fold: &fold::Fold<Ctxt>, +doc: doc::NmodDoc) -> doc::NmodDoc {
|
||||
fold.ctxt.path.pop();
|
||||
|
||||
doc::NmodDoc {
|
||||
item: (fold.fold_item)(fold, doc.item),
|
||||
item: (fold.fold_item)(fold, copy doc.item),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ fn is_hidden(srv: astsrv::Srv, doc: doc::ItemDoc) -> bool {
|
||||
let id = doc.id;
|
||||
do astsrv::exec(srv) |ctxt| {
|
||||
let attrs = match ctxt.ast_map.get(id) {
|
||||
ast_map::node_item(item, _) => item.attrs,
|
||||
ast_map::node_item(item, _) => copy item.attrs,
|
||||
_ => ~[]
|
||||
};
|
||||
attr_parser::parse_hidden(attrs)
|
||||
@ -77,7 +77,7 @@ pub mod test {
|
||||
use prune_hidden_pass::run;
|
||||
|
||||
pub fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
do astsrv::from_str(copy source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
run(srv, doc)
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ pub mod test {
|
||||
use prune_private_pass::run;
|
||||
|
||||
pub fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
do astsrv::from_str(copy source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
run(srv, doc)
|
||||
}
|
||||
|
@ -23,10 +23,8 @@
|
||||
#[legacy_modes];
|
||||
#[legacy_records];
|
||||
|
||||
#[allow(vecs_implicitly_copyable)];
|
||||
#[allow(non_implicitly_copyable_typarams)];
|
||||
#[allow(deprecated_mode)];
|
||||
#[allow(deprecated_pattern)];
|
||||
#[allow(deprecated_self)];
|
||||
|
||||
extern mod core(vers = "0.6");
|
||||
@ -93,7 +91,7 @@ fn main() {
|
||||
/// Runs rustdoc over the given file
|
||||
fn run(config: Config) {
|
||||
|
||||
let source_file = config.input_crate;
|
||||
let source_file = copy config.input_crate;
|
||||
|
||||
// Create an AST service from the source code
|
||||
do astsrv::from_file(source_file.to_str()) |srv| {
|
||||
@ -106,7 +104,7 @@ fn run(config: Config) {
|
||||
// Extract the initial doc tree from the AST. This contains
|
||||
// just names and node ids.
|
||||
let doc = time(~"extract", || {
|
||||
let default_name = source_file;
|
||||
let default_name = copy source_file;
|
||||
extract::from_srv(srv, default_name.to_str())
|
||||
});
|
||||
|
||||
@ -138,13 +136,13 @@ fn run(config: Config) {
|
||||
// Sort items again by kind
|
||||
sort_item_type_pass::mk_pass(),
|
||||
// Create indexes appropriate for markdown
|
||||
markdown_index_pass::mk_pass(config),
|
||||
markdown_index_pass::mk_pass(copy 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)
|
||||
markdown_writer::make_writer_factory(copy config)
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ fn fold_trait(fold: &fold::Fold<()>, +doc: doc::TraitDoc) -> doc::TraitDoc {
|
||||
doc::MethodDoc {
|
||||
desc: desc,
|
||||
sections: sections,
|
||||
.. *method
|
||||
.. copy *method
|
||||
}
|
||||
},
|
||||
.. doc
|
||||
@ -80,7 +80,7 @@ fn fold_impl(fold: &fold::Fold<()>, +doc: doc::ImplDoc) -> doc::ImplDoc {
|
||||
doc::MethodDoc {
|
||||
desc: desc,
|
||||
sections: sections,
|
||||
.. *method
|
||||
.. copy *method
|
||||
}
|
||||
},
|
||||
.. doc
|
||||
@ -109,17 +109,17 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
|
||||
return (None, ~[]);
|
||||
}
|
||||
|
||||
let lines = str::lines(desc.get());
|
||||
let lines = str::lines((copy desc).get());
|
||||
|
||||
let mut new_desc = None::<~str>;
|
||||
let mut current_section = None;
|
||||
let mut sections = ~[];
|
||||
|
||||
for lines.each |line| {
|
||||
match parse_header(*line) {
|
||||
match parse_header(copy *line) {
|
||||
Some(header) => {
|
||||
if current_section.is_some() {
|
||||
sections += ~[current_section.get()];
|
||||
sections += ~[(¤t_section).get()];
|
||||
}
|
||||
current_section = Some(doc::Section {
|
||||
header: header,
|
||||
@ -135,12 +135,12 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
|
||||
});
|
||||
}
|
||||
None => {
|
||||
new_desc = match new_desc {
|
||||
new_desc = match copy new_desc {
|
||||
Some(desc) => {
|
||||
Some(desc + ~"\n" + *line)
|
||||
}
|
||||
None => {
|
||||
Some(*line)
|
||||
Some(copy *line)
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -260,7 +260,7 @@ pub mod test {
|
||||
use sectionalize_pass::run;
|
||||
|
||||
pub fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
do astsrv::from_str(copy source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
let doc = (attr_pass::mk_pass().f)(srv, doc);
|
||||
run(srv, doc)
|
||||
|
@ -29,7 +29,7 @@ type ItemLtEq = NominalOp<ItemLtEqOp>;
|
||||
|
||||
pub fn mk_pass(name: ~str, +lteq: ItemLtEqOp) -> Pass {
|
||||
Pass {
|
||||
name: name,
|
||||
name: copy name,
|
||||
f: fn~(move lteq, srv: astsrv::Srv, +doc: doc::Doc) -> doc::Doc {
|
||||
run(srv, doc, NominalOp { op: copy lteq })
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use std::par;
|
||||
|
||||
pub fn mk_pass(name: ~str, +op: fn~(~str) -> ~str) -> Pass {
|
||||
Pass {
|
||||
name: name,
|
||||
name: copy name,
|
||||
f: fn~(move op, srv: astsrv::Srv, +doc: doc::Doc) -> doc::Doc {
|
||||
run(srv, doc, copy op)
|
||||
}
|
||||
@ -53,7 +53,7 @@ fn run(
|
||||
}
|
||||
|
||||
fn maybe_apply_op(op: NominalOp<Op>, s: Option<~str>) -> Option<~str> {
|
||||
s.map(|s| (op.op)(*s) )
|
||||
s.map(|s| (op.op)(copy *s) )
|
||||
}
|
||||
|
||||
fn fold_item(
|
||||
@ -65,7 +65,7 @@ fn fold_item(
|
||||
doc::ItemDoc {
|
||||
brief: maybe_apply_op(fold.ctxt, doc.brief),
|
||||
desc: maybe_apply_op(fold.ctxt, doc.desc),
|
||||
sections: apply_to_sections(fold.ctxt, doc.sections),
|
||||
sections: apply_to_sections(fold.ctxt, copy doc.sections),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -75,8 +75,8 @@ fn apply_to_sections(
|
||||
sections: ~[doc::Section]
|
||||
) -> ~[doc::Section] {
|
||||
par::map(sections, |section, copy op| doc::Section {
|
||||
header: (op.op)(section.header),
|
||||
body: (op.op)(section.body)
|
||||
header: (op.op)(copy section.header),
|
||||
body: (op.op)(copy section.body)
|
||||
})
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ fn fold_enum(
|
||||
variants: do par::map(doc.variants) |variant, copy fold_copy| {
|
||||
doc::VariantDoc {
|
||||
desc: maybe_apply_op(fold_copy.ctxt, variant.desc),
|
||||
.. *variant
|
||||
.. copy *variant
|
||||
}
|
||||
},
|
||||
.. doc
|
||||
@ -104,7 +104,7 @@ fn fold_trait(
|
||||
let doc = fold::default_seq_fold_trait(fold, doc);
|
||||
|
||||
doc::TraitDoc {
|
||||
methods: apply_to_methods(fold.ctxt, doc.methods),
|
||||
methods: apply_to_methods(fold.ctxt, copy doc.methods),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -117,8 +117,8 @@ fn apply_to_methods(
|
||||
doc::MethodDoc {
|
||||
brief: maybe_apply_op(op, doc.brief),
|
||||
desc: maybe_apply_op(op, doc.desc),
|
||||
sections: apply_to_sections(op, doc.sections),
|
||||
.. *doc
|
||||
sections: apply_to_sections(op, copy doc.sections),
|
||||
.. copy *doc
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,7 +130,7 @@ fn fold_impl(
|
||||
let doc = fold::default_seq_fold_impl(fold, doc);
|
||||
|
||||
doc::ImplDoc {
|
||||
methods: apply_to_methods(fold.ctxt, doc.methods),
|
||||
methods: apply_to_methods(fold.ctxt, copy doc.methods),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -302,7 +302,7 @@ mod test {
|
||||
use core::str;
|
||||
|
||||
pub fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
do astsrv::from_str(copy source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
let doc = (attr_pass::mk_pass().f)(srv, doc);
|
||||
let doc = (desc_to_brief_pass::mk_pass().f)(srv, doc);
|
||||
|
@ -44,7 +44,7 @@ mod test {
|
||||
use trim_pass::mk_pass;
|
||||
|
||||
pub fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
do astsrv::from_str(copy source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
let doc = (attr_pass::mk_pass().f)(srv, doc);
|
||||
(mk_pass().f)(srv, doc)
|
||||
|
@ -70,13 +70,14 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
|
||||
match ctxt.ast_map.get(fn_id) {
|
||||
ast_map::node_item(@ast::item {
|
||||
ident: ident,
|
||||
node: ast::item_fn(decl, _, tys, _), _
|
||||
node: ast::item_fn(ref decl, _, ref tys, _), _
|
||||
}, _) |
|
||||
ast_map::node_foreign_item(@ast::foreign_item {
|
||||
ident: ident,
|
||||
node: ast::foreign_item_fn(decl, _, tys), _
|
||||
node: ast::foreign_item_fn(ref decl, _, ref tys), _
|
||||
}, _, _) => {
|
||||
Some(pprust::fun_to_str(decl, ident, tys, extract::interner()))
|
||||
Some(pprust::fun_to_str(*decl, ident, copy *tys,
|
||||
extract::interner()))
|
||||
}
|
||||
_ => fail ~"get_fn_sig: fn_id not bound to a fn item"
|
||||
}
|
||||
@ -102,7 +103,7 @@ fn fold_const(
|
||||
let srv = fold.ctxt;
|
||||
|
||||
doc::SimpleItemDoc {
|
||||
sig: Some(do astsrv::exec(srv) |ctxt| {
|
||||
sig: Some(do astsrv::exec(srv) |copy doc, ctxt| {
|
||||
match ctxt.ast_map.get(doc.id()) {
|
||||
ast_map::node_item(@ast::item {
|
||||
node: ast::item_const(ty, _), _
|
||||
@ -131,11 +132,11 @@ fn fold_enum(
|
||||
|
||||
doc::EnumDoc {
|
||||
variants: do par::map(doc.variants) |variant| {
|
||||
let variant = *variant;
|
||||
let sig = do astsrv::exec(srv) |ctxt| {
|
||||
let variant = copy *variant;
|
||||
let sig = do astsrv::exec(srv) |copy variant, ctxt| {
|
||||
match ctxt.ast_map.get(doc_id) {
|
||||
ast_map::node_item(@ast::item {
|
||||
node: ast::item_enum(enum_definition, _), _
|
||||
node: ast::item_enum(ref enum_definition, _), _
|
||||
}, _) => {
|
||||
let ast_variant =
|
||||
do vec::find(enum_definition.variants) |v| {
|
||||
@ -168,7 +169,7 @@ fn fold_trait(
|
||||
+doc: doc::TraitDoc
|
||||
) -> doc::TraitDoc {
|
||||
doc::TraitDoc {
|
||||
methods: merge_methods(fold.ctxt, doc.id(), doc.methods),
|
||||
methods: merge_methods(fold.ctxt, doc.id(), copy doc.methods),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -180,8 +181,8 @@ fn merge_methods(
|
||||
) -> ~[doc::MethodDoc] {
|
||||
do par::map(docs) |doc| {
|
||||
doc::MethodDoc {
|
||||
sig: get_method_sig(srv, item_id, doc.name),
|
||||
.. *doc
|
||||
sig: get_method_sig(srv, item_id, copy doc.name),
|
||||
.. copy *doc
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -191,13 +192,13 @@ fn get_method_sig(
|
||||
item_id: doc::AstId,
|
||||
method_name: ~str
|
||||
) -> Option<~str> {
|
||||
do astsrv::exec(srv) |ctxt| {
|
||||
do astsrv::exec(srv) |copy method_name, ctxt| {
|
||||
match ctxt.ast_map.get(item_id) {
|
||||
ast_map::node_item(@ast::item {
|
||||
node: ast::item_trait(_, _, methods), _
|
||||
node: ast::item_trait(_, _, ref methods), _
|
||||
}, _) => {
|
||||
match vec::find(methods, |method| {
|
||||
match *method {
|
||||
match vec::find(*methods, |method| {
|
||||
match copy *method {
|
||||
ast::required(ty_m) => to_str(ty_m.ident) == method_name,
|
||||
ast::provided(m) => to_str(m.ident) == method_name,
|
||||
}
|
||||
@ -208,7 +209,7 @@ fn get_method_sig(
|
||||
Some(pprust::fun_to_str(
|
||||
ty_m.decl,
|
||||
ty_m.ident,
|
||||
ty_m.tps,
|
||||
copy ty_m.tps,
|
||||
extract::interner()
|
||||
))
|
||||
}
|
||||
@ -216,7 +217,7 @@ fn get_method_sig(
|
||||
Some(pprust::fun_to_str(
|
||||
m.decl,
|
||||
m.ident,
|
||||
m.tps,
|
||||
copy m.tps,
|
||||
extract::interner()
|
||||
))
|
||||
}
|
||||
@ -226,16 +227,16 @@ fn get_method_sig(
|
||||
}
|
||||
}
|
||||
ast_map::node_item(@ast::item {
|
||||
node: ast::item_impl(_, _, _, methods), _
|
||||
node: ast::item_impl(_, _, _, ref methods), _
|
||||
}, _) => {
|
||||
match vec::find(methods, |method| {
|
||||
match vec::find(*methods, |method| {
|
||||
to_str(method.ident) == method_name
|
||||
}) {
|
||||
Some(method) => {
|
||||
Some(pprust::fun_to_str(
|
||||
method.decl,
|
||||
method.ident,
|
||||
method.tps,
|
||||
copy method.tps,
|
||||
extract::interner()
|
||||
))
|
||||
}
|
||||
@ -261,7 +262,7 @@ fn fold_impl(
|
||||
|
||||
let srv = fold.ctxt;
|
||||
|
||||
let (trait_types, self_ty) = do astsrv::exec(srv) |ctxt| {
|
||||
let (trait_types, self_ty) = do astsrv::exec(srv) |copy doc, ctxt| {
|
||||
match ctxt.ast_map.get(doc.id()) {
|
||||
ast_map::node_item(@ast::item {
|
||||
node: ast::item_impl(_, opt_trait_type, self_ty, _), _
|
||||
@ -279,7 +280,7 @@ fn fold_impl(
|
||||
doc::ImplDoc {
|
||||
trait_types: trait_types,
|
||||
self_ty: self_ty,
|
||||
methods: merge_methods(fold.ctxt, doc.id(), doc.methods),
|
||||
methods: merge_methods(fold.ctxt, doc.id(), copy doc.methods),
|
||||
.. doc
|
||||
}
|
||||
}
|
||||
@ -317,16 +318,16 @@ fn fold_type(
|
||||
let srv = fold.ctxt;
|
||||
|
||||
doc::SimpleItemDoc {
|
||||
sig: do astsrv::exec(srv) |ctxt| {
|
||||
sig: do astsrv::exec(srv) |copy doc, ctxt| {
|
||||
match ctxt.ast_map.get(doc.id()) {
|
||||
ast_map::node_item(@ast::item {
|
||||
ident: ident,
|
||||
node: ast::item_ty(ty, params), _
|
||||
node: ast::item_ty(ty, ref params), _
|
||||
}, _) => {
|
||||
Some(fmt!(
|
||||
"type %s%s = %s",
|
||||
to_str(ident),
|
||||
pprust::typarams_to_str(params, extract::interner()),
|
||||
pprust::typarams_to_str(*params, extract::interner()),
|
||||
pprust::ty_to_str(ty, extract::interner())
|
||||
))
|
||||
}
|
||||
@ -350,7 +351,7 @@ fn fold_struct(
|
||||
let srv = fold.ctxt;
|
||||
|
||||
doc::StructDoc {
|
||||
sig: do astsrv::exec(srv) |ctxt| {
|
||||
sig: do astsrv::exec(srv) |copy doc, ctxt| {
|
||||
match ctxt.ast_map.get(doc.id()) {
|
||||
ast_map::node_item(item, _) => {
|
||||
let item = strip_struct_extra_stuff(item);
|
||||
@ -369,11 +370,11 @@ fn fold_struct(
|
||||
/// should be a simple pprust::struct_to_str function that does
|
||||
/// what I actually want
|
||||
fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
|
||||
let node = match item.node {
|
||||
let node = match copy item.node {
|
||||
ast::item_struct(def, tys) => {
|
||||
let def = @ast::struct_def {
|
||||
dtor: None, // Remove the drop { } block
|
||||
.. *def
|
||||
.. copy *def
|
||||
};
|
||||
ast::item_struct(def, tys)
|
||||
}
|
||||
@ -383,28 +384,28 @@ fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
|
||||
@ast::item {
|
||||
attrs: ~[], // Remove the attributes
|
||||
node: node,
|
||||
.. *item
|
||||
.. copy *item
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_add_struct_defs() {
|
||||
let doc = test::mk_doc(~"struct S { field: () }");
|
||||
assert doc.cratemod().structs()[0].sig.get().contains("struct S {");
|
||||
assert (&doc.cratemod().structs()[0].sig).get().contains("struct S {");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_serialize_struct_drop_blocks() {
|
||||
// All we care about are the fields
|
||||
let doc = test::mk_doc(~"struct S { field: (), drop { } }");
|
||||
assert !doc.cratemod().structs()[0].sig.get().contains("drop");
|
||||
assert !(&doc.cratemod().structs()[0].sig).get().contains("drop");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_serialize_struct_attrs() {
|
||||
// All we care about are the fields
|
||||
let doc = test::mk_doc(~"#[wut] struct S { field: () }");
|
||||
assert !doc.cratemod().structs()[0].sig.get().contains("wut");
|
||||
assert !(&doc.cratemod().structs()[0].sig).get().contains("wut");
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -415,7 +416,7 @@ pub mod test {
|
||||
use tystr_pass::run;
|
||||
|
||||
pub fn mk_doc(source: ~str) -> doc::Doc {
|
||||
do astsrv::from_str(source) |srv| {
|
||||
do astsrv::from_str(copy source) |srv| {
|
||||
let doc = extract::from_srv(srv, ~"");
|
||||
run(srv, doc)
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ fn unindent(s: ~str) -> ~str {
|
||||
let unindented = ~[str::trim(vec::head(lines))]
|
||||
+ do par::map(vec::tail(lines)) |line| {
|
||||
if str::is_whitespace(*line) {
|
||||
*line
|
||||
copy *line
|
||||
} else {
|
||||
assert str::len(*line) >= min_indent;
|
||||
str::slice(*line, min_indent, str::len(*line))
|
||||
@ -90,7 +90,7 @@ fn unindent(s: ~str) -> ~str {
|
||||
};
|
||||
str::connect(unindented, ~"\n")
|
||||
} else {
|
||||
s
|
||||
copy s
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user