diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-02-17 17:48:37 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-02-17 17:48:37 -0800 |
| commit | affd83ea0e119e719b8b0cfd598bcd4c909b8b75 (patch) | |
| tree | c39b356b0affee003cc76820e9150b79de9549eb /src/rustdoc/path_pass.rs | |
| parent | f8f28e29be16131afe71bd3854d645b87664495b (diff) | |
| download | rust-affd83ea0e119e719b8b0cfd598bcd4c909b8b75.tar.gz rust-affd83ea0e119e719b8b0cfd598bcd4c909b8b75.zip | |
rustdoc: Find the path to all item types
Diffstat (limited to 'src/rustdoc/path_pass.rs')
| -rw-r--r-- | src/rustdoc/path_pass.rs | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/rustdoc/path_pass.rs b/src/rustdoc/path_pass.rs index 2bfa5cfa5b5..d4730e9faba 100644 --- a/src/rustdoc/path_pass.rs +++ b/src/rustdoc/path_pass.rs @@ -15,28 +15,29 @@ fn run(srv: astsrv::srv, doc: doc::cratedoc) -> doc::cratedoc { mutable path: [] }; let fold = fold::fold({ - fold_mod: fn~( - f: fold::fold<ctxt>, - d: doc::moddoc - ) -> doc::moddoc { - fold_mod(f, d) - } + fold_item: fold_item, + fold_mod: fold_mod with *fold::default_seq_fold(ctxt) }); fold.fold_crate(fold, doc) } +fn fold_item(fold: fold::fold<ctxt>, doc: doc::itemdoc) -> doc::itemdoc { + { + path: fold.ctxt.path + with doc + } +} + fn fold_mod(fold: fold::fold<ctxt>, doc: doc::moddoc) -> doc::moddoc { let is_topmod = doc.id() == rustc::syntax::ast::crate_node_id; if !is_topmod { vec::push(fold.ctxt.path, doc.name()); } let doc = fold::default_seq_fold_mod(fold, doc); if !is_topmod { vec::pop(fold.ctxt.path); } + { - item: { - path: fold.ctxt.path - with doc.item - } + item: fold.fold_item(fold, doc.item) with doc } } @@ -47,6 +48,16 @@ fn should_record_mod_paths() { let srv = astsrv::mk_srv_from_str(source); let doc = extract::from_srv(srv, ""); let doc = run(srv, doc); + log(error, doc.topmod.mods()[0].mods()[0].mods()[0].path()); assert doc.topmod.mods()[0].mods()[0].mods()[0].path() == ["a", "b"]; assert doc.topmod.mods()[0].mods()[1].mods()[0].path() == ["a", "d"]; +} + +#[test] +fn should_record_fn_paths() { + let source = "mod a { fn b() { } }"; + let srv = astsrv::mk_srv_from_str(source); + let doc = extract::from_srv(srv, ""); + let doc = run(srv, doc); + assert doc.topmod.mods()[0].fns()[0].path() == ["a"]; } \ No newline at end of file |
