rustdoc: Fix some remaining bugs around native mods

This commit is contained in:
Brian Anderson
2012-02-24 15:22:57 -08:00
parent 6e31983179
commit 9b009ea23d
2 changed files with 20 additions and 1 deletions

View File

@@ -158,6 +158,9 @@ fn should_write_crate_description() {
}
fn write_nmod(ctxt: ctxt, doc: doc::nmoddoc) {
let fullpath = str::connect(doc.path() + [doc.name()], "::");
write_header(ctxt, h1, #fmt("Native module `%s`", fullpath));
write_brief(ctxt, doc.brief());
write_desc(ctxt, doc.desc());
@@ -169,6 +172,8 @@ fn write_nmod(ctxt: ctxt, doc: doc::nmoddoc) {
#[test]
fn should_write_native_mods() {
let markdown = test::render("#[doc = \"test\"] native mod a { }");
log(error, markdown);
assert str::contains(markdown, "Native module `a`");
assert str::contains(markdown, "test");
}

View File

@@ -47,7 +47,11 @@ fn fold_nmod(fold: fold::fold<ctxt>, doc: doc::nmoddoc) -> doc::nmoddoc {
vec::push(fold.ctxt.path, doc.name());
let doc = fold::default_seq_fold_nmod(fold, doc);
vec::pop(fold.ctxt.path);
ret doc;
{
item: fold.fold_item(fold, doc.item)
with doc
}
}
#[test]
@@ -71,6 +75,16 @@ fn should_record_fn_paths() {
}
}
#[test]
fn should_record_native_mod_paths() {
let source = "mod a { native mod b { } }";
astsrv::from_str(source) {|srv|
let doc = extract::from_srv(srv, "");
let doc = run(srv, doc);
assert doc.topmod.mods()[0].nmods()[0].path() == ["a"];
}
}
#[test]
fn should_record_native_fn_paths() {
let source = "native mod a { fn b(); }";