rust/src/rustdoc/sort_item_name_pass.rs

23 lines
581 B
Rust
Raw Normal View History

//! Sorts items by name
2012-02-03 12:00:49 -08:00
2012-09-05 10:41:47 -07:00
use doc::item_utils;
2012-02-03 12:00:49 -08:00
export mk_pass;
fn mk_pass() -> pass {
pure fn by_item_name(item1: &doc::itemtag, item2: &doc::itemtag) -> bool {
(*item1).name() <= (*item2).name()
}
sort_pass::mk_pass(~"sort_item_name", by_item_name)
2012-02-03 12:00:49 -08:00
}
#[test]
fn test() {
let source = ~"mod z { } fn y() { }";
2012-06-30 16:19:07 -07:00
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv, ~"");
2012-02-27 18:07:16 -08:00
let doc = mk_pass().f(srv, doc);
assert doc.cratemod().items[0].name() == ~"y";
assert doc.cratemod().items[1].name() == ~"z";
}
2012-02-03 12:00:49 -08:00
}