diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-08-03 19:59:04 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-08-05 22:08:09 -0700 |
| commit | 025d86624de982cdab7e6b13600fec1499c02b56 (patch) | |
| tree | 96ba196f8a420c52e6034acd14f323d3d2239e29 /src/rustdoc | |
| parent | c9d27693796fe4ced8568e11aa465750f743097b (diff) | |
Switch alts to use arrows
Diffstat (limited to 'src/rustdoc')
| -rw-r--r-- | src/rustdoc/astsrv.rs | 4 | ||||
| -rw-r--r-- | src/rustdoc/attr_parser.rs | 12 | ||||
| -rw-r--r-- | src/rustdoc/attr_pass.rs | 20 | ||||
| -rw-r--r-- | src/rustdoc/config.rs | 24 | ||||
| -rw-r--r-- | src/rustdoc/desc_to_brief_pass.rs | 8 | ||||
| -rw-r--r-- | src/rustdoc/doc.rs | 84 | ||||
| -rw-r--r-- | src/rustdoc/extract.rs | 26 | ||||
| -rw-r--r-- | src/rustdoc/fold.rs | 20 | ||||
| -rw-r--r-- | src/rustdoc/markdown_index_pass.rs | 4 | ||||
| -rw-r--r-- | src/rustdoc/markdown_pass.rs | 72 | ||||
| -rw-r--r-- | src/rustdoc/markdown_writer.rs | 24 | ||||
| -rw-r--r-- | src/rustdoc/page_pass.rs | 6 | ||||
| -rw-r--r-- | src/rustdoc/prune_hidden_pass.rs | 4 | ||||
| -rwxr-xr-x | src/rustdoc/rustdoc.rs | 4 | ||||
| -rw-r--r-- | src/rustdoc/sectionalize_pass.rs | 12 | ||||
| -rw-r--r-- | src/rustdoc/sort_item_type_pass.rs | 16 | ||||
| -rw-r--r-- | src/rustdoc/tystr_pass.rs | 30 |
17 files changed, 183 insertions, 187 deletions
diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index cd931578c32..58341e2152d 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -78,10 +78,10 @@ fn act(po: comm::port<msg>, source: ~str, parse: parser) { let mut keep_going = true; while keep_going { alt comm::recv(po) { - handle_request(f) { + handle_request(f) => { f(ctxt); } - exit { + exit => { keep_going = false; } } diff --git a/src/rustdoc/attr_parser.rs b/src/rustdoc/attr_parser.rs index 97f6ae2e81f..ba633111a6a 100644 --- a/src/rustdoc/attr_parser.rs +++ b/src/rustdoc/attr_parser.rs @@ -94,10 +94,10 @@ fn should_not_extract_crate_name_if_no_name_value_in_link_attribute() { fn parse_desc(attrs: ~[ast::attribute]) -> option<~str> { alt doc_meta(attrs) { - some(meta) { + some(meta) => { attr::get_meta_item_value_str(meta).map(|x| *x ) } - none { none } + none => none } } @@ -119,16 +119,16 @@ fn parse_desc_should_parse_simple_doc_attributes() { fn parse_hidden(attrs: ~[ast::attribute]) -> bool { alt doc_meta(attrs) { - some(meta) { + some(meta) => { alt attr::get_meta_item_list(meta) { - some(metas) { + some(metas) => { let hiddens = attr::find_meta_items_by_name(metas, ~"hidden"); vec::is_not_empty(hiddens) } - none { false } + none => false } } - none { false } + none => false } } diff --git a/src/rustdoc/attr_pass.rs b/src/rustdoc/attr_pass.rs index e22f3a1c9bb..9c55ebc4a95 100644 --- a/src/rustdoc/attr_pass.rs +++ b/src/rustdoc/attr_pass.rs @@ -94,11 +94,9 @@ fn parse_item_attrs<T:send>( +parse_attrs: fn~(~[ast::attribute]) -> T) -> T { do astsrv::exec(srv) |ctxt| { let attrs = alt ctxt.ast_map.get(id) { - ast_map::node_item(item, _) { item.attrs } - ast_map::node_foreign_item(item, _, _) { item.attrs } - _ { - fail ~"parse_item_attrs: not an item"; - } + ast_map::node_item(item, _) => item.attrs, + ast_map::node_foreign_item(item, _, _) => item.attrs, + _ => fail ~"parse_item_attrs: not an item" }; parse_attrs(attrs) } @@ -149,7 +147,7 @@ fn fold_enum( alt check ctxt.ast_map.get(doc_id) { ast_map::node_item(@{ node: ast::item_enum(ast_variants, _), _ - }, _) { + }, _) => { let ast_variant = option::get( vec::find(ast_variants, |v| { *v.node.name == variant.name @@ -206,13 +204,13 @@ fn merge_method_attrs( alt ctxt.ast_map.get(item_id) { ast_map::node_item(@{ node: ast::item_trait(_, _, methods), _ - }, _) { + }, _) => { vec::map(methods, |method| { alt method { - ast::required(ty_m) { + ast::required(ty_m) => { (*ty_m.ident, attr_parser::parse_desc(ty_m.attrs)) } - ast::provided(m) { + ast::provided(m) => { (*m.ident, attr_parser::parse_desc(m.attrs)) } } @@ -220,12 +218,12 @@ fn merge_method_attrs( } ast_map::node_item(@{ node: ast::item_impl(_, _, _, methods), _ - }, _) { + }, _) => { vec::map(methods, |method| { (*method.ident, attr_parser::parse_desc(method.attrs)) }) } - _ { fail ~"unexpected item" } + _ => fail ~"unexpected item" } }; diff --git a/src/rustdoc/config.rs b/src/rustdoc/config.rs index 5300ebe1a3b..398892d715f 100644 --- a/src/rustdoc/config.rs +++ b/src/rustdoc/config.rs @@ -101,7 +101,7 @@ fn parse_config_( let args = vec::tail(args); let opts = vec::unzip(opts()).first(); alt getopts::getopts(args, opts) { - result::ok(matches) { + result::ok(matches) => { if vec::len(matches.free) == 1u { let input_crate = vec::head(matches.free); config_from_opts(input_crate, matches, program_output) @@ -111,7 +111,7 @@ fn parse_config_( result::err(~"multiple crates specified") } } - result::err(f) { + result::err(f) => { result::err(getopts::fail_str(f)) } } @@ -177,17 +177,17 @@ fn config_from_opts( fn parse_output_format(output_format: ~str) -> result<output_format, ~str> { alt output_format { - ~"markdown" { result::ok(markdown) } - ~"html" { result::ok(pandoc_html) } - _ { result::err(fmt!{"unknown output format '%s'", output_format}) } + ~"markdown" => result::ok(markdown), + ~"html" => result::ok(pandoc_html), + _ => result::err(fmt!{"unknown output format '%s'", output_format}) } } fn parse_output_style(output_style: ~str) -> result<output_style, ~str> { alt output_style { - ~"doc-per-crate" { result::ok(doc_per_crate) } - ~"doc-per-mod" { result::ok(doc_per_mod) } - _ { result::err(fmt!{"unknown output style '%s'", output_style}) } + ~"doc-per-crate" => result::ok(doc_per_crate), + ~"doc-per-mod" => result::ok(doc_per_mod), + _ => result::err(fmt!{"unknown output style '%s'", output_style}) } } @@ -201,13 +201,13 @@ fn maybe_find_pandoc( } let possible_pandocs = alt maybe_pandoc_cmd { - some(pandoc_cmd) { ~[pandoc_cmd] } - none { + some(pandoc_cmd) => ~[pandoc_cmd], + none => { ~[~"pandoc"] + alt os::homedir() { - some(dir) { + some(dir) => { ~[path::connect(dir, ~".cabal/bin/pandoc")] } - none { ~[] } + none => ~[] } } }; diff --git a/src/rustdoc/desc_to_brief_pass.rs b/src/rustdoc/desc_to_brief_pass.rs index 37a76f936d2..76c74c71ef4 100644 --- a/src/rustdoc/desc_to_brief_pass.rs +++ b/src/rustdoc/desc_to_brief_pass.rs @@ -105,14 +105,14 @@ fn parse_desc(desc: ~str) -> option<~str> { const max_brief_len: uint = 120u; alt first_sentence(desc) { - some(first_sentence) { + some(first_sentence) => { if str::len(first_sentence) <= max_brief_len { some(first_sentence) } else { none } } - none { none } + none => none } } @@ -144,10 +144,10 @@ fn first_sentence_(s: ~str) -> ~str { } }; alt idx { - some(idx) if idx > 2u { + some(idx) if idx > 2u => { str::slice(s, 0u, idx - 1u) } - _ { + _ => { if str::ends_with(s, ~".") { str::slice(s, 0u, str::len(s)) } else { diff --git a/src/rustdoc/doc.rs b/src/rustdoc/doc.rs index 9e1fd812fc3..723bcff5fb0 100644 --- a/src/rustdoc/doc.rs +++ b/src/rustdoc/doc.rs @@ -142,8 +142,8 @@ impl util for doc { fn cratedoc() -> cratedoc { option::get(vec::foldl(none, self.pages, |_m, page| { alt page { - doc::cratepage(doc) { some(doc) } - _ { none } + doc::cratepage(doc) => some(doc), + _ => none } })) } @@ -159,8 +159,8 @@ impl util for moddoc { fn mods() -> ~[moddoc] { do vec::filter_map(self.items) |itemtag| { alt itemtag { - modtag(moddoc) { some(moddoc) } - _ { none } + modtag(moddoc) => some(moddoc), + _ => none } } } @@ -168,8 +168,8 @@ impl util for moddoc { fn nmods() -> ~[nmoddoc] { do vec::filter_map(self.items) |itemtag| { alt itemtag { - nmodtag(nmoddoc) { some(nmoddoc) } - _ { none } + nmodtag(nmoddoc) => some(nmoddoc), + _ => none } } } @@ -177,8 +177,8 @@ impl util for moddoc { fn fns() -> ~[fndoc] { do vec::filter_map(self.items) |itemtag| { alt itemtag { - fntag(fndoc) { some(fndoc) } - _ { none } + fntag(fndoc) => some(fndoc), + _ => none } } } @@ -186,8 +186,8 @@ impl util for moddoc { fn consts() -> ~[constdoc] { do vec::filter_map(self.items) |itemtag| { alt itemtag { - consttag(constdoc) { some(constdoc) } - _ { none } + consttag(constdoc) => some(constdoc), + _ => none } } } @@ -195,8 +195,8 @@ impl util for moddoc { fn enums() -> ~[enumdoc] { do vec::filter_map(self.items) |itemtag| { alt itemtag { - enumtag(enumdoc) { some(enumdoc) } - _ { none } + enumtag(enumdoc) => some(enumdoc), + _ => none } } } @@ -204,8 +204,8 @@ impl util for moddoc { fn traits() -> ~[traitdoc] { do vec::filter_map(self.items) |itemtag| { alt itemtag { - traittag(traitdoc) { some(traitdoc) } - _ { none } + traittag(traitdoc) => some(traitdoc), + _ => none } } } @@ -213,8 +213,8 @@ impl util for moddoc { fn impls() -> ~[impldoc] { do vec::filter_map(self.items) |itemtag| { alt itemtag { - impltag(impldoc) { some(impldoc) } - _ { none } + impltag(impldoc) => some(impldoc), + _ => none } } } @@ -222,8 +222,8 @@ impl util for moddoc { fn types() -> ~[tydoc] { do vec::filter_map(self.items) |itemtag| { alt itemtag { - tytag(tydoc) { some(tydoc) } - _ { none } + tytag(tydoc) => some(tydoc), + _ => none } } } @@ -245,8 +245,8 @@ impl util of page_utils for ~[page] { fn mods() -> ~[moddoc] { do vec::filter_map(self) |page| { alt page { - itempage(modtag(moddoc)) { some(moddoc) } - _ { none } + itempage(modtag(moddoc)) => some(moddoc), + _ => none } } } @@ -254,8 +254,8 @@ impl util of page_utils for ~[page] { fn nmods() -> ~[nmoddoc] { do vec::filter_map(self) |page| { alt page { - itempage(nmodtag(nmoddoc)) { some(nmoddoc) } - _ { none } + itempage(nmodtag(nmoddoc)) => some(nmoddoc), + _ => none } } } @@ -263,8 +263,8 @@ impl util of page_utils for ~[page] { fn fns() -> ~[fndoc] { do vec::filter_map(self) |page| { alt page { - itempage(fntag(fndoc)) { some(fndoc) } - _ { none } + itempage(fntag(fndoc)) => some(fndoc), + _ => none } } } @@ -272,8 +272,8 @@ impl util of page_utils for ~[page] { fn consts() -> ~[constdoc] { do vec::filter_map(self) |page| { alt page { - itempage(consttag(constdoc)) { some(constdoc) } - _ { none } + itempage(consttag(constdoc)) => some(constdoc), + _ => none } } } @@ -281,8 +281,8 @@ impl util of page_utils for ~[page] { fn enums() -> ~[enumdoc] { do vec::filter_map(self) |page| { alt page { - itempage(enumtag(enumdoc)) { some(enumdoc) } - _ { none } + itempage(enumtag(enumdoc)) => some(enumdoc), + _ => none } } } @@ -290,8 +290,8 @@ impl util of page_utils for ~[page] { fn traits() -> ~[traitdoc] { do vec::filter_map(self) |page| { alt page { - itempage(traittag(traitdoc)) { some(traitdoc) } - _ { none } + itempage(traittag(traitdoc)) => some(traitdoc), + _ => none } } } @@ -299,8 +299,8 @@ impl util of page_utils for ~[page] { fn impls() -> ~[impldoc] { do vec::filter_map(self) |page| { alt page { - itempage(impltag(impldoc)) { some(impldoc) } - _ { none } + itempage(impltag(impldoc)) => some(impldoc), + _ => none } } } @@ -308,8 +308,8 @@ impl util of page_utils for ~[page] { fn types() -> ~[tydoc] { do vec::filter_map(self) |page| { alt page { - itempage(tytag(tydoc)) { some(tydoc) } - _ { none } + itempage(tytag(tydoc)) => some(tydoc), + _ => none } } } @@ -322,14 +322,14 @@ trait item { impl of item for itemtag { pure fn item() -> itemdoc { alt 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::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 } } } diff --git a/src/rustdoc/extract.rs b/src/rustdoc/extract.rs index a6c653de326..7d56efcc4ee 100644 --- a/src/rustdoc/extract.rs +++ b/src/rustdoc/extract.rs @@ -59,49 +59,47 @@ fn moddoc_from_mod( items: do vec::filter_map(module_.items) |item| { let itemdoc = mk_itemdoc(item.id, item.ident); alt item.node { - ast::item_mod(m) { + ast::item_mod(m) => { some(doc::modtag( moddoc_from_mod(itemdoc, m) )) } - ast::item_foreign_mod(nm) { + ast::item_foreign_mod(nm) => { some(doc::nmodtag( nmoddoc_from_mod(itemdoc, nm) )) } - ast::item_fn(_, _, _) { + ast::item_fn(_, _, _) => { some(doc::fntag( fndoc_from_fn(itemdoc) )) } - ast::item_const(_, _) { + ast::item_const(_, _) => { some(doc::consttag( constdoc_from_const(itemdoc) )) } - ast::item_enum(variants, _) { + ast::item_enum(variants, _) => { some(doc::enumtag( enumdoc_from_enum(itemdoc, variants) )) } - ast::item_trait(_, _, methods) { + ast::item_trait(_, _, methods) => { some(doc::traittag( traitdoc_from_trait(itemdoc, methods) )) } - ast::item_impl(_, _, _, methods) { + ast::item_impl(_, _, _, methods) => { some(doc::impltag( impldoc_from_impl(itemdoc, methods) )) } - ast::item_ty(_, _) { + ast::item_ty(_, _) => { some(doc::tytag( tydoc_from_ty(itemdoc) )) } - _ { - none - } + _ => none } }, index: none @@ -117,7 +115,7 @@ fn nmoddoc_from_mod( fns: do vec::map(module_.items) |item| { let itemdoc = mk_itemdoc(item.id, item.ident); alt item.node { - ast::foreign_item_fn(_, _) { + ast::foreign_item_fn(_, _) => { fndoc_from_fn(itemdoc) } } @@ -192,7 +190,7 @@ fn traitdoc_from_trait( item: itemdoc, methods: do vec::map(methods) |method| { alt method { - ast::required(ty_m) { + ast::required(ty_m) => { { name: *ty_m.ident, brief: none, @@ -202,7 +200,7 @@ fn traitdoc_from_trait( implementation: doc::required, } } - ast::provided(m) { + ast::provided(m) => { { name: *m.ident, brief: none, diff --git a/src/rustdoc/fold.rs b/src/rustdoc/fold.rs index 11b90deecbd..b848c6b8899 100644 --- a/src/rustdoc/fold.rs +++ b/src/rustdoc/fold.rs @@ -135,10 +135,10 @@ fn default_seq_fold_doc<T>(fold: fold<T>, doc: doc::doc) -> doc::doc { doc::doc_({ pages: do vec::map(doc.pages) |page| { alt page { - doc::cratepage(doc) { + doc::cratepage(doc) => { doc::cratepage(fold.fold_crate(fold, doc)) } - doc::itempage(doc) { + doc::itempage(doc) => { doc::itempage(fold_itemtag(fold, doc)) } } @@ -243,28 +243,28 @@ fn default_par_fold_nmod<T:send copy>( fn fold_itemtag<T>(fold: fold<T>, doc: doc::itemtag) -> doc::itemtag { alt doc { - doc::modtag(moddoc) { + doc::modtag(moddoc) => { doc::modtag(fold.fold_mod(fold, moddoc)) } - doc::nmodtag(nmoddoc) { + doc::nmodtag(nmoddoc) => { doc::nmodtag(fold.fold_nmod(fold, nmoddoc)) } - doc::fntag(fndoc) { + doc::fntag(fndoc) => { doc::fntag(fold.fold_fn(fold, fndoc)) } - doc::consttag(constdoc) { + doc::consttag(constdoc) => { doc::consttag(fold.fold_const(fold, constdoc)) } - doc::enumtag(enumdoc) { + doc::enumtag(enumdoc) => { doc::enumtag(fold.fold_enum(fold, enumdoc)) } - doc::traittag(traitdoc) { + doc::traittag(traitdoc) => { doc::traittag(fold.fold_trait(fold, traitdoc)) } - doc::impltag(impldoc) { + doc::impltag(impldoc) => { doc::impltag(fold.fold_impl(fold, impldoc)) } - doc::tytag(tydoc) { + doc::tytag(tydoc) => { doc::tytag(fold.fold_type(fold, tydoc)) } } diff --git a/src/rustdoc/markdown_index_pass.rs b/src/rustdoc/markdown_index_pass.rs index 7280786db7e..123ad89ecd4 100644 --- a/src/rustdoc/markdown_index_pass.rs +++ b/src/rustdoc/markdown_index_pass.rs @@ -80,10 +80,10 @@ fn item_to_entry( ) -> doc::index_entry { let link = alt doc { doc::modtag(_) | doc::nmodtag(_) - if config.output_style == config::doc_per_mod { + if config.output_style == config::doc_per_mod => { markdown_writer::make_filename(config, doc::itempage(doc)) } - _ { + _ => { ~"#" + pandoc_header_id(markdown_pass::header_text(doc)) } }; diff --git a/src/rustdoc/markdown_pass.rs b/src/rustdoc/markdown_pass.rs index c8f767bf716..90d00d292b1 100644 --- a/src/rustdoc/markdown_pass.rs +++ b/src/rustdoc/markdown_pass.rs @@ -29,8 +29,8 @@ fn run( pure fn mods_last(item1: &doc::itemtag, item2: &doc::itemtag) -> bool { pure fn is_mod(item: &doc::itemtag) -> bool { alt *item { - doc::modtag(_) { true } - _ { false } + doc::modtag(_) => true, + _ => false } } @@ -95,10 +95,10 @@ fn write_markdown( fn write_page(ctxt: ctxt, page: doc::page) { write_title(ctxt, page); alt page { - doc::cratepage(doc) { + doc::cratepage(doc) => { write_crate(ctxt, doc); } - doc::itempage(doc) { + doc::itempage(doc) => { // We don't write a header for item's pages because their // header in the html output is created by the page title write_item_no_header(ctxt, doc); @@ -129,10 +129,10 @@ fn write_title(ctxt: ctxt, page: doc::page) { fn make_title(page: doc::page) -> ~str { let item = alt page { - doc::cratepage(cratedoc) { + doc::cratepage(cratedoc) => { doc::modtag(cratedoc.topmod) } - doc::itempage(itemtag) { + doc::itempage(itemtag) => { itemtag } }; @@ -151,10 +151,10 @@ fn should_write_title_for_each_page() { for iter::repeat(2u) { let (page, markdown) = comm::recv(po); alt page { - doc::cratepage(_) { + doc::cratepage(_) => { assert str::contains(markdown, ~"% Crate core"); } - doc::itempage(_) { + doc::itempage(_) => { assert str::contains(markdown, ~"% Module a"); } } @@ -181,32 +181,32 @@ fn write_header_(ctxt: ctxt, lvl: hlvl, title: ~str) { fn header_kind(doc: doc::itemtag) -> ~str { alt doc { - doc::modtag(_) { + doc::modtag(_) => { if doc.id() == syntax::ast::crate_node_id { ~"Crate" } else { ~"Module" } } - doc::nmodtag(_) { + doc::nmodtag(_) => { ~"Foreign module" } - doc::fntag(_) { + doc::fntag(_) => { ~"Function" } - doc::consttag(_) { + doc::consttag(_) => { ~"Const" } - doc::enumtag(_) { + doc::enumtag(_) => { ~"Enum" } - doc::traittag(_) { + doc::traittag(_) => { ~"Interface" } - doc::impltag(doc) { + doc::impltag(doc) => { ~"Implementation" } - doc::tytag(_) { + doc::tytag(_) => { ~"Type" } } @@ -215,13 +215,13 @@ fn header_kind(doc: doc::itemtag) -> ~str { fn header_name(doc: doc::itemtag) -> ~str { let fullpath = str::connect(doc.path() + ~[doc.name()], ~"::"); alt doc { - doc::modtag(_) if doc.id() != syntax::ast::crate_node_id { + doc::modtag(_) if doc.id() != syntax::ast::crate_node_id => { fullpath } - doc::nmodtag(_) { + doc::nmodtag(_) => { fullpath } - doc::impltag(doc) { + doc::impltag(doc) => { assert option::is_some(doc.self_ty); let self_ty = option::get(doc.self_ty); let mut trait_part = ~""; @@ -235,7 +235,7 @@ fn header_name(doc: doc::itemtag) -> ~str { } fmt!{"%s%s for %s", doc.name(), trait_part, self_ty} } - _ { + _ => { doc.name() } } @@ -290,11 +290,11 @@ fn write_desc( desc: option<~str> ) { alt desc { - some(desc) { + some(desc) => { ctxt.w.write_line(desc); ctxt.w.write_line(~""); } - none { } + none => () } } @@ -348,14 +348,14 @@ fn write_item_(ctxt: ctxt, doc: doc::itemtag, write_header: bool) { } alt doc { - doc::modtag(moddoc) { write_mod(ctxt, moddoc) } - doc::nmodtag(nmoddoc) { write_nmod(ctxt, nmoddoc) } - doc::fntag(fndoc) { write_fn(ctxt, fndoc) } - doc::consttag(constdoc) { write_const(ctxt, constdoc) } - doc::enumtag(enumdoc) { write_enum(ctxt, enumdoc) } - doc::traittag(traitdoc) { write_trait(ctxt, traitdoc) } - doc::impltag(impldoc) { write_impl(ctxt, impldoc) } - doc::tytag(tydoc) { write_type(ctxt, tydoc) } + doc::modtag(moddoc) => write_mod(ctxt, moddoc), + doc::nmodtag(nmoddoc) => write_nmod(ctxt, nmoddoc), + doc::fntag(fndoc) => write_fn(ctxt, fndoc), + doc::consttag(constdoc) => write_const(ctxt, constdoc), + doc::enumtag(enumdoc) => write_enum(ctxt, enumdoc), + doc::traittag(traitdoc) => write_trait(ctxt, traitdoc), + doc::impltag(impldoc) => write_impl(ctxt, impldoc), + doc::tytag(tydoc) => write_type(ctxt, tydoc) } } @@ -365,8 +365,8 @@ fn write_item_header(ctxt: ctxt, doc: doc::itemtag) { fn item_header_lvl(doc: doc::itemtag) -> hlvl { alt doc { - doc::modtag(_) | doc::nmodtag(_) { h1 } - _ { h2 } + doc::modtag(_) | doc::nmodtag(_) => h1, + _ => h2 } } @@ -482,11 +482,11 @@ fn write_fnlike( fn write_sig(ctxt: ctxt, sig: option<~str>) { alt sig { - some(sig) { + some(sig) => { ctxt.w.write_line(code_block_indent(sig)); ctxt.w.write_line(~""); } - none { fail ~"unimplemented" } + none => fail ~"unimplemented" } } @@ -603,10 +603,10 @@ fn write_variant(ctxt: ctxt, doc: doc::variantdoc) { assert option::is_some(doc.sig); let sig = option::get(doc.sig); alt doc.desc { - some(desc) { + some(desc) => { ctxt.w.write_line(fmt!{"* `%s` - %s", sig, desc}); } - none { + none => { ctxt.w.write_line(fmt!{"* `%s`", sig}); } } diff --git a/src/rustdoc/markdown_writer.rs b/src/rustdoc/markdown_writer.rs index 08e39ba53da..3f46f8f3d5b 100644 --- a/src/rustdoc/markdown_writer.rs +++ b/src/rustdoc/markdown_writer.rs @@ -39,10 +39,10 @@ impl writer_util of writer_utils for writer { fn make_writer_factory(config: config::config) -> writer_factory { alt config.output_format { - config::markdown { + config::markdown => { markdown_writer_factory(config) } - config::pandoc_html { + config::pandoc_html => { pandoc_writer_factory(config) } } @@ -151,8 +151,8 @@ fn generic_writer(+process: fn~(markdown: ~str)) -> writer { let mut keep_going = true; while keep_going { alt comm::recv(po) { - write(s) { markdown += s; } - done { keep_going = false; } + write(s) => markdown += s, + done => keep_going = false } } process(markdown); @@ -177,7 +177,7 @@ fn make_filename( ) -> ~str { let filename = { alt page { - doc::cratepage(doc) { + doc::cratepage(doc) => { if config.output_format == config::pandoc_html && config.output_style == config::doc_per_mod { ~"index" @@ -186,14 +186,14 @@ fn make_filename( doc.topmod.name() } } - doc::itempage(doc) { + doc::itempage(doc) => { str::connect(doc.path() + ~[doc.name()], ~"_") } } }; let ext = alt config.output_format { - config::markdown { ~"md" } - config::pandoc_html { ~"html" } + config::markdown => ~"md", + config::pandoc_html => ~"html" }; filename + ~"." + ext @@ -257,10 +257,10 @@ fn write_file(path: ~str, s: ~str) { import io::writer_util; alt io::file_writer(path, ~[io::create, io::truncate]) { - result::ok(writer) { + result::ok(writer) => { writer.write_str(s); } - result::err(e) { fail e } + result::err(e) => fail e } } @@ -293,8 +293,8 @@ fn future_writer() -> (writer, future::future<~str>) { let mut res = ~""; loop { alt comm::recv(port) { - write(s) { res += s } - done { break; } + write(s) => res += s, + done => break } } res diff --git a/src/rustdoc/page_pass.rs b/src/rustdoc/page_pass.rs index eed559367d3..11cf4f735cf 100644 --- a/src/rustdoc/page_pass.rs +++ b/src/rustdoc/page_pass.rs @@ -107,9 +107,9 @@ fn strip_mod(doc: doc::moddoc) -> doc::moddoc { doc::moddoc_({ items: do vec::filter(doc.items) |item| { alt item { - doc::modtag(_) { false } - doc::nmodtag(_) { false } - _ { true } + doc::modtag(_) => false, + doc::nmodtag(_) => false, + _ => true } } with *doc diff --git a/src/rustdoc/prune_hidden_pass.rs b/src/rustdoc/prune_hidden_pass.rs index dbb65f0e2d1..d8060257a63 100644 --- a/src/rustdoc/prune_hidden_pass.rs +++ b/src/rustdoc/prune_hidden_pass.rs @@ -39,8 +39,8 @@ fn is_hidden(srv: astsrv::srv, doc: doc::itemdoc) -> bool { let id = doc.id; do astsrv::exec(srv) |ctxt| { let attrs = alt ctxt.ast_map.get(id) { - ast_map::node_item(item, _) { item.attrs } - _ { ~[] } + ast_map::node_item(item, _) => item.attrs, + _ => ~[] }; attr_parser::parse_hidden(attrs) } diff --git a/src/rustdoc/rustdoc.rs b/src/rustdoc/rustdoc.rs index b6d225df98e..015da4b52d8 100755 --- a/src/rustdoc/rustdoc.rs +++ b/src/rustdoc/rustdoc.rs @@ -108,8 +108,8 @@ fn main(args: ~[~str]) { } let config = alt config::parse_config(args) { - result::ok(config) { config } - result::err(err) { + result::ok(config) => config, + result::err(err) => { io::println(fmt!{"error: %s", err}); return; } diff --git a/src/rustdoc/sectionalize_pass.rs b/src/rustdoc/sectionalize_pass.rs index 41771966881..29bebdf10e5 100644 --- a/src/rustdoc/sectionalize_pass.rs +++ b/src/rustdoc/sectionalize_pass.rs @@ -96,7 +96,7 @@ fn sectionalize(desc: option<~str>) -> (option<~str>, ~[doc::section]) { for lines.each |line| { alt parse_header(line) { - some(header) { + some(header) => { if option::is_some(current_section) { sections += ~[option::get(current_section)]; } @@ -105,20 +105,20 @@ fn sectionalize(desc: option<~str>) -> (option<~str>, ~[doc::section]) { body: ~"" }); } - none { + none => { alt copy current_section { - some(section) { + some(section) => { current_section = some({ body: section.body + ~"\n" + line with section }); } - none { + none => { new_desc = alt new_desc { - some(desc) { + some(desc) => { some(desc + ~"\n" + line) } - none { + none => { some(line) } }; diff --git a/src/rustdoc/sort_item_type_pass.rs b/src/rustdoc/sort_item_type_pass.rs index c7d185fb8a3..afa299345dc 100644 --- a/src/rustdoc/sort_item_type_pass.rs +++ b/src/rustdoc/sort_item_type_pass.rs @@ -8,14 +8,14 @@ fn mk_pass() -> pass { pure fn by_score(item1: &doc::itemtag, item2: &doc::itemtag) -> bool { pure fn score(item: &doc::itemtag) -> int { alt *item { - doc::consttag(_) { 0 } - doc::tytag(_) { 1 } - doc::enumtag(_) { 2 } - doc::traittag(_) { 3 } - doc::impltag(_) { 4 } - doc::fntag(_) { 5 } - doc::modtag(_) { 6 } - doc::nmodtag(_) { 7 } + doc::consttag(_) => 0, + doc::tytag(_) => 1, + doc::enumtag(_) => 2, + doc::traittag(_) => 3, + doc::impltag(_) => 4, + doc::fntag(_) => 5, + doc::modtag(_) => 6, + doc::nmodtag(_) => 7 } } diff --git a/src/rustdoc/tystr_pass.rs b/src/rustdoc/tystr_pass.rs index ce1f921af27..a2ae6d5eba4 100644 --- a/src/rustdoc/tystr_pass.rs +++ b/src/rustdoc/tystr_pass.rs @@ -54,7 +54,7 @@ fn get_fn_sig(srv: astsrv::srv, fn_id: doc::ast_id) -> option<~str> { ast_map::node_foreign_item(@{ ident: ident, node: ast::foreign_item_fn(decl, tys), _ - }, _, _) { + }, _, _) => { some(pprust::fun_to_str(decl, ident, tys)) } } @@ -84,7 +84,7 @@ fn fold_const( alt check ctxt.ast_map.get(doc.id()) { ast_map::node_item(@{ node: ast::item_const(ty, _), _ - }, _) { + }, _) => { pprust::ty_to_str(ty) } } @@ -112,7 +112,7 @@ fn fold_enum( alt check ctxt.ast_map.get(doc_id) { ast_map::node_item(@{ node: ast::item_enum(ast_variants, _), _ - }, _) { + }, _) => { let ast_variant = option::get( do vec::find(ast_variants) |v| { *v.node.name == variant.name @@ -170,23 +170,23 @@ fn get_method_sig( alt check ctxt.ast_map.get(item_id) { ast_map::node_item(@{ node: ast::item_trait(_, _, methods), _ - }, _) { + }, _) => { alt check vec::find(methods, |method| { alt method { - ast::required(ty_m) { *ty_m.ident == method_name } - ast::provided(m) { *m.ident == method_name } + ast::required(ty_m) => *ty_m.ident == method_name, + ast::provided(m) => *m.ident == method_name, } }) { - some(method) { + some(method) => { alt method { - ast::required(ty_m) { + ast::required(ty_m) => { some(pprust::fun_to_str( ty_m.decl, ty_m.ident, ty_m.tps )) } - ast::provided(m) { + ast::provided(m) => { some(pprust::fun_to_str( m.decl, m.ident, @@ -199,11 +199,11 @@ fn get_method_sig( } ast_map::node_item(@{ node: ast::item_impl(_, _, _, methods), _ - }, _) { + }, _) => { alt check vec::find(methods, |method| { *method.ident == method_name }) { - some(method) { + some(method) => { some(pprust::fun_to_str( method.decl, method.ident, @@ -234,13 +234,13 @@ fn fold_impl( alt ctxt.ast_map.get(doc.id()) { ast_map::node_item(@{ node: ast::item_impl(_, trait_types, self_ty, _), _ - }, _) { + }, _) => { let trait_types = vec::map(trait_types, |p| { pprust::path_to_str(p.path) }); (trait_types, some(pprust::ty_to_str(self_ty))) } - _ { fail ~"expected impl" } + _ => fail ~"expected impl" } }; @@ -290,7 +290,7 @@ fn fold_type( ast_map::node_item(@{ ident: ident, node: ast::item_ty(ty, params), _ - }, _) { + }, _) => { some(fmt!{ "type %s%s = %s", *ident, @@ -298,7 +298,7 @@ fn fold_type( pprust::ty_to_str(ty) }) } - _ { fail ~"expected type" } + _ => fail ~"expected type" } } with doc |
