Skip to content

Commit 5a86313

Browse files
committed
rustdoc: Write markdown for native mods and fns
1 parent 1601005 commit 5a86313

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/rustdoc/markdown_pass.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fn write_mod_contents(
133133
for itemtag in doc.items {
134134
alt itemtag {
135135
doc::modtag(moddoc) { write_mod(ctxt, moddoc) }
136-
doc::nmodtag(_) { fail }
136+
doc::nmodtag(nmoddoc) { write_nmod(ctxt, nmoddoc) }
137137
doc::fntag(fndoc) { write_fn(ctxt, fndoc) }
138138
doc::consttag(constdoc) { write_const(ctxt, constdoc) }
139139
doc::enumtag(enumdoc) { write_enum(ctxt, enumdoc) }
@@ -157,6 +157,27 @@ fn should_write_crate_description() {
157157
assert str::contains(markdown, "this is the crate");
158158
}
159159

160+
fn write_nmod(ctxt: ctxt, doc: doc::nmoddoc) {
161+
write_brief(ctxt, doc.brief());
162+
write_desc(ctxt, doc.desc());
163+
164+
for fndoc in doc.fns {
165+
write_fn(ctxt, fndoc);
166+
}
167+
}
168+
169+
#[test]
170+
fn should_write_native_mods() {
171+
let markdown = test::render("#[doc = \"test\"] native mod a { }");
172+
assert str::contains(markdown, "test");
173+
}
174+
175+
#[test]
176+
fn should_write_native_fns() {
177+
let markdown = test::render("native mod a { #[doc = \"test\"] fn a(); }");
178+
assert str::contains(markdown, "test");
179+
}
180+
160181
fn write_fn(
161182
ctxt: ctxt,
162183
doc: doc::fndoc

0 commit comments

Comments
 (0)