rustdoc: Write a new file for each page
This commit is contained in:
parent
fbd8a76e8a
commit
fc9b55d65f
|
@ -82,14 +82,41 @@ fn write_markdown(
|
||||||
doc: doc::doc,
|
doc: doc::doc,
|
||||||
writer_factory: writer_factory
|
writer_factory: writer_factory
|
||||||
) {
|
) {
|
||||||
|
for page in doc.pages {
|
||||||
let ctxt = {
|
let ctxt = {
|
||||||
w: writer_factory(doc::cratepage(doc.cratedoc()))
|
w: writer_factory(page)
|
||||||
};
|
};
|
||||||
|
write_page(ctxt, page);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
write_crate(ctxt, doc.cratedoc());
|
fn write_page(ctxt: ctxt, page: doc::page) {
|
||||||
|
alt page {
|
||||||
|
doc::cratepage(doc) {
|
||||||
|
write_crate(ctxt, doc);
|
||||||
|
}
|
||||||
|
doc::itempage(doc) {
|
||||||
|
write_item(ctxt, doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
ctxt.w.write_done();
|
ctxt.w.write_done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_request_new_writer_for_each_page() {
|
||||||
|
// This port will send us a (page, str) pair for every writer
|
||||||
|
// that was created
|
||||||
|
let (writer_factory, po) = markdown_writer::future_writer_factory();
|
||||||
|
let (srv, doc) = test::create_doc_srv("mod a { }");
|
||||||
|
// Split the document up into pages
|
||||||
|
let doc = page_pass::mk_pass(config::doc_per_mod).f(srv, doc);
|
||||||
|
write_markdown(doc, writer_factory);
|
||||||
|
// We expect two pages to have been written
|
||||||
|
iter::repeat(2u) {||
|
||||||
|
comm::recv(po);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum hlvl {
|
enum hlvl {
|
||||||
h1 = 1,
|
h1 = 1,
|
||||||
h2 = 2,
|
h2 = 2,
|
||||||
|
@ -218,7 +245,12 @@ fn write_mod_contents(
|
||||||
}
|
}
|
||||||
|
|
||||||
for itemtag in doc.items {
|
for itemtag in doc.items {
|
||||||
alt itemtag {
|
write_item(ctxt, itemtag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_item(ctxt: ctxt, doc: doc::itemtag) {
|
||||||
|
alt doc {
|
||||||
doc::modtag(moddoc) { write_mod(ctxt, moddoc) }
|
doc::modtag(moddoc) { write_mod(ctxt, moddoc) }
|
||||||
doc::nmodtag(nmoddoc) { write_nmod(ctxt, nmoddoc) }
|
doc::nmodtag(nmoddoc) { write_nmod(ctxt, nmoddoc) }
|
||||||
doc::fntag(fndoc) { write_fn(ctxt, fndoc) }
|
doc::fntag(fndoc) { write_fn(ctxt, fndoc) }
|
||||||
|
@ -229,7 +261,6 @@ fn write_mod_contents(
|
||||||
doc::impltag(impldoc) { write_impl(ctxt, impldoc) }
|
doc::impltag(impldoc) { write_impl(ctxt, impldoc) }
|
||||||
doc::tytag(tydoc) { write_type(ctxt, tydoc) }
|
doc::tytag(tydoc) { write_type(ctxt, tydoc) }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -152,6 +152,7 @@ fn run(config: config::config) {
|
||||||
sort_item_name_pass::mk_pass(),
|
sort_item_name_pass::mk_pass(),
|
||||||
sort_item_type_pass::mk_pass(),
|
sort_item_type_pass::mk_pass(),
|
||||||
markdown_index_pass::mk_pass(),
|
markdown_index_pass::mk_pass(),
|
||||||
|
page_pass::mk_pass(config.output_style),
|
||||||
markdown_pass::mk_pass(
|
markdown_pass::mk_pass(
|
||||||
markdown_writer::make_writer_factory(config)
|
markdown_writer::make_writer_factory(config)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue