Skip to content

Commit 9b009ea

Browse files
committed
rustdoc: Fix some remaining bugs around native mods
1 parent 6e31983 commit 9b009ea

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/rustdoc/markdown_pass.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ fn should_write_crate_description() {
158158
}
159159

160160
fn write_nmod(ctxt: ctxt, doc: doc::nmoddoc) {
161+
let fullpath = str::connect(doc.path() + [doc.name()], "::");
162+
write_header(ctxt, h1, #fmt("Native module `%s`", fullpath));
163+
161164
write_brief(ctxt, doc.brief());
162165
write_desc(ctxt, doc.desc());
163166

@@ -169,6 +172,8 @@ fn write_nmod(ctxt: ctxt, doc: doc::nmoddoc) {
169172
#[test]
170173
fn should_write_native_mods() {
171174
let markdown = test::render("#[doc = \"test\"] native mod a { }");
175+
log(error, markdown);
176+
assert str::contains(markdown, "Native module `a`");
172177
assert str::contains(markdown, "test");
173178
}
174179

src/rustdoc/path_pass.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ fn fold_nmod(fold: fold::fold<ctxt>, doc: doc::nmoddoc) -> doc::nmoddoc {
4747
vec::push(fold.ctxt.path, doc.name());
4848
let doc = fold::default_seq_fold_nmod(fold, doc);
4949
vec::pop(fold.ctxt.path);
50-
ret doc;
50+
51+
{
52+
item: fold.fold_item(fold, doc.item)
53+
with doc
54+
}
5155
}
5256

5357
#[test]
@@ -71,6 +75,16 @@ fn should_record_fn_paths() {
7175
}
7276
}
7377

78+
#[test]
79+
fn should_record_native_mod_paths() {
80+
let source = "mod a { native mod b { } }";
81+
astsrv::from_str(source) {|srv|
82+
let doc = extract::from_srv(srv, "");
83+
let doc = run(srv, doc);
84+
assert doc.topmod.mods()[0].nmods()[0].path() == ["a"];
85+
}
86+
}
87+
7488
#[test]
7589
fn should_record_native_fn_paths() {
7690
let source = "native mod a { fn b(); }";

0 commit comments

Comments
 (0)