about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-05-23 19:01:33 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-05-25 01:18:10 -0700
commit5ee3d0e1ffa6e190d73815ba4754b2618528c83e (patch)
treef93f663d0b488186126936b517e8213cfd57221a
parent9181c35ee925240fc129d77695e3f88c6d5f0f2b (diff)
downloadrust-5ee3d0e1ffa6e190d73815ba4754b2618528c83e.tar.gz
rust-5ee3d0e1ffa6e190d73815ba4754b2618528c83e.zip
rustdoc: Inline reexported modules
-rw-r--r--src/librustdoc/clean.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs
index 79f687b0624..a78e9d1d1fb 100644
--- a/src/librustdoc/clean.rs
+++ b/src/librustdoc/clean.rs
@@ -1575,8 +1575,12 @@ fn try_inline(id: ast::NodeId) -> Option<Vec<Item>> {
     };
     let did = ast_util::def_id_of_def(def);
     if ast_util::is_local(did) { return None }
+    try_inline_def(tcx, def)
+}
 
+fn try_inline_def(tcx: &ty::ctxt, def: ast::Def) -> Option<Vec<Item>> {
     let mut ret = Vec::new();
+    let did = ast_util::def_id_of_def(def);
     let inner = match def {
         ast::DefTrait(did) => TraitItem(build_external_trait(tcx, did)),
         ast::DefFn(did, style) =>
@@ -1592,6 +1596,7 @@ fn try_inline(id: ast::NodeId) -> Option<Vec<Item>> {
         // Assume that the enum type is reexported next to the variant, and
         // variants don't show up in documentation specially.
         ast::DefVariant(..) => return Some(Vec::new()),
+        ast::DefMod(did) => ModuleItem(build_module(tcx, did)),
         _ => return None,
     };
     let fqn = csearch::get_item_path(tcx, did);
@@ -1995,6 +2000,28 @@ fn build_impl(tcx: &ty::ctxt, did: ast::DefId) -> Item {
     }
 }
 
+fn build_module(tcx: &ty::ctxt, did: ast::DefId) -> Module {
+    let mut items = Vec::new();
+
+    csearch::each_child_of_item(&tcx.sess.cstore, did, |def, _, _| {
+        match def {
+            decoder::DlDef(def) => {
+                match try_inline_def(tcx, def) {
+                    Some(i) => items.extend(i.move_iter()),
+                    None => {}
+                }
+            }
+            decoder::DlImpl(did) => items.push(build_impl(tcx, did)),
+            decoder::DlField => fail!("unimplemented field"),
+        }
+    });
+
+    Module {
+        items: items,
+        is_crate: false,
+    }
+}
+
 fn resolve_use_source(path: Path, id: ast::NodeId) -> ImportSource {
     ImportSource {
         path: path,