rustdoc: Put native mods on their own pages. Closes #1959

This commit is contained in:
Brian Anderson 2012-03-10 16:44:48 -08:00
parent 474ad2e4de
commit a5368fb6d8
2 changed files with 41 additions and 2 deletions

View File

@ -52,7 +52,8 @@ fn item_to_entry(
config: config::config
) -> doc::index_entry {
let link = alt doc {
doc::modtag(_) if config.output_style == config::doc_per_mod {
doc::modtag(_) | doc::nmodtag(_)
if config.output_style == config::doc_per_mod {
markdown_writer::make_filename(config, doc::itempage(doc))
}
_ {
@ -148,6 +149,20 @@ fn should_index_mod_contents_multi_page() {
};
}
#[test]
fn should_index_native_mod_pages() {
let doc = test::mk_doc(
config::doc_per_mod,
"native mod a { }"
);
assert option::get(doc.cratemod().index).entries[0] == {
kind: "Native module",
name: "a",
brief: none,
link: "a.html"
};
}
#[test]
fn should_add_brief_desc_to_index() {
let doc = test::mk_doc(

View File

@ -59,7 +59,8 @@ fn make_doc_from_pages(page_port: page_port) -> doc::doc {
fn find_pages(doc: doc::doc, page_chan: page_chan) {
let fold = fold::fold({
fold_crate: fold_crate,
fold_mod: fold_mod
fold_mod: fold_mod,
fold_nmod: fold_nmod
with *fold::default_any_fold(page_chan)
});
fold.fold_doc(fold, doc);
@ -106,6 +107,7 @@ fn strip_mod(doc: doc::moddoc) -> doc::moddoc {
items: vec::filter(doc.items) {|item|
alt item {
doc::modtag(_) { false }
doc::nmodtag(_) { false }
_ { true }
}
}
@ -113,6 +115,16 @@ fn strip_mod(doc: doc::moddoc) -> doc::moddoc {
}
}
fn fold_nmod(
fold: fold::fold<page_chan>,
doc: doc::nmoddoc
) -> doc::nmoddoc {
let doc = fold::default_seq_fold_nmod(fold, doc);
let page = doc::itempage(doc::nmodtag(doc));
comm::send(fold.ctxt, some(page));
ret doc;
}
#[test]
fn should_not_split_the_doc_into_pages_for_doc_per_crate() {
let doc = test::mk_doc_(
@ -134,6 +146,18 @@ fn should_remove_mods_from_containing_mods() {
assert vec::is_empty(doc.cratemod().mods());
}
#[test]
fn should_make_a_page_for_every_native_mod() {
let doc = test::mk_doc("native mod a { }");
assert doc.pages.nmods()[0].name() == "a";
}
#[test]
fn should_remove_native_mods_from_containing_mods() {
let doc = test::mk_doc("native mod a { }");
assert vec::is_empty(doc.cratemod().nmods());
}
#[cfg(test)]
mod test {
fn mk_doc_(