]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Change the header scheme so that all mods are h2, fns h3
authorBrian Anderson <banderson@mozilla.com>
Thu, 19 Jan 2012 07:54:56 +0000 (23:54 -0800)
committerBrian Anderson <banderson@mozilla.com>
Thu, 19 Jan 2012 08:04:59 +0000 (00:04 -0800)
src/rustdoc/gen.rs

index 160576617d44f6f38ef93054c5089ec931b0f845..6c42c476b2f517cc061bad942bf8bd80bf11fbd6 100644 (file)
@@ -18,8 +18,7 @@ fn mk_pass(
 }
 
 type ctxt = {
-    w: io::writer,
-    mutable depth: uint
+    w: io::writer
 };
 
 fn write_markdown(
@@ -27,30 +26,29 @@ fn write_markdown(
     writer: io::writer
 ) {
     let ctxt = {
-        w: writer,
-        mutable depth: 1u
+        w: writer
     };
 
     write_crate(ctxt, doc);
 }
 
-fn write_header(ctxt: ctxt, title: str) {
-    let hashes = str::from_chars(vec::init_elt('#', ctxt.depth));
-    ctxt.w.write_line(#fmt("%s %s", hashes, title));
-    ctxt.w.write_line("");
+tag hlvl {
+    h1 = 1;
+    h2 = 2;
+    h3 = 3;
 }
 
-fn subsection(ctxt: ctxt, f: fn&()) {
-    ctxt.depth += 1u;
-    f();
-    ctxt.depth -= 1u;
+fn write_header(ctxt: ctxt, lvl: hlvl, title: str) {
+    let hashes = str::from_chars(vec::init_elt('#', lvl as uint));
+    ctxt.w.write_line(#fmt("%s %s", hashes, title));
+    ctxt.w.write_line("");
 }
 
 fn write_crate(
     ctxt: ctxt,
     doc: doc::cratedoc
 ) {
-    write_header(ctxt, #fmt("Crate %s", doc.topmod.name));
+    write_header(ctxt, h1, #fmt("Crate %s", doc.topmod.name));
     write_top_module(ctxt, doc.topmod);
 }
 
@@ -65,7 +63,7 @@ fn write_mod(
     ctxt: ctxt,
     moddoc: doc::moddoc
 ) {
-    write_header(ctxt, #fmt("Module `%s`", moddoc.name));
+    write_header(ctxt, h2, #fmt("Module `%s`", moddoc.name));
     write_mod_contents(ctxt, moddoc);
 }
 
@@ -77,15 +75,11 @@ fn write_mod_contents(
     write_desc(ctxt, doc.desc);
 
     for fndoc in *doc.fns {
-        subsection(ctxt) {||
-            write_fn(ctxt, fndoc);
-        }
+        write_fn(ctxt, fndoc);
     }
 
     for moddoc in *doc.mods {
-        subsection(ctxt) {||
-            write_mod(ctxt, moddoc);
-        }
+        write_mod(ctxt, moddoc);
     }
 }
 
@@ -105,7 +99,7 @@ fn write_fn(
     ctxt: ctxt,
     doc: doc::fndoc
 ) {
-    write_header(ctxt, #fmt("Function `%s`", doc.name));
+    write_header(ctxt, h3, #fmt("Function `%s`", doc.name));
     write_brief(ctxt, doc.brief);
     write_desc(ctxt, doc.desc);
     write_args(ctxt, doc.args);