Skip to content

Commit dc69355

Browse files
committed
rustdoc: Generate markdown for failure conditions
1 parent 3310112 commit dc69355

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/rustdoc/gen.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ fn write_fn(
116116
write_desc(ctxt, doc.desc);
117117
write_args(ctxt, doc.args);
118118
write_return(ctxt, doc.return);
119+
write_failure(ctxt, doc.failure);
119120
}
120121

121122
fn write_sig(ctxt: ctxt, sig: option<str>) {
@@ -304,6 +305,25 @@ fn should_write_return_description_on_same_line_as_type() {
304305
assert str::contains(markdown, "Returns `int` - blorp");
305306
}
306307

308+
fn write_failure(ctxt: ctxt, str: option<str>) {
309+
alt str {
310+
some(str) {
311+
ctxt.w.write_line(#fmt("Failure conditions: %s", str));
312+
ctxt.w.write_line("");
313+
}
314+
none { }
315+
}
316+
}
317+
318+
#[test]
319+
fn should_write_failure_conditions() {
320+
let markdown = test::render(
321+
"#[doc(failure = \"it's the fail\")] fn a () { }");
322+
assert str::contains(
323+
markdown,
324+
"\n\nFailure conditions: it's the fail\n\n");
325+
}
326+
307327
fn write_const(
308328
ctxt: ctxt,
309329
doc: doc::constdoc

0 commit comments

Comments
 (0)