rustdoc: Write crate name
This commit is contained in:
parent
ae584263da
commit
d928952191
@ -3,6 +3,19 @@ type ctxt = {
|
||||
w: io::writer
|
||||
};
|
||||
|
||||
fn write_markdown(
|
||||
doc: doc::cratedoc,
|
||||
_crate: @ast::crate,
|
||||
writer: io::writer
|
||||
) {
|
||||
let ctxt = {
|
||||
ps: pprust::rust_printer(writer),
|
||||
w: writer
|
||||
};
|
||||
|
||||
write_header(ctxt, doc.topmod.name);
|
||||
}
|
||||
|
||||
#[doc(
|
||||
brief = "Generate a crate document header.",
|
||||
args(rd = "Rustdoc context",
|
||||
@ -46,3 +59,25 @@ fn write_fndoc(ctxt: ctxt, ident: str, doc: doc::fndoc, decl: ast::fn_decl) {
|
||||
none. { }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
fn write_markdown_str(
|
||||
doc: doc::cratedoc,
|
||||
crate: @ast::crate
|
||||
) -> str {
|
||||
let buffer = io::mk_mem_buffer();
|
||||
let writer = io::mem_buffer_writer(buffer);
|
||||
write_markdown(doc, crate, writer);
|
||||
ret io::mem_buffer_str(buffer);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn write_markdown_should_write_crate_header() {
|
||||
let source = "";
|
||||
let ast = parse::from_str(source);
|
||||
let doc = extract::extract(ast, "belch");
|
||||
let markdown = write_markdown_str(doc, ast);
|
||||
assert str::contains(markdown, "# Crate belch\n");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user