about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-01-18 23:54:56 -0800
committerBrian Anderson <banderson@mozilla.com>2012-01-19 00:04:59 -0800
commit42e5d451b7c3aacf6e6a589f4e67e23eda4cd3ad (patch)
treef83222d1b3480a754d2882df304cd2db6deb123b /src
parenta5e0f037be17204c640e2941e576a9dca09efc90 (diff)
downloadrust-42e5d451b7c3aacf6e6a589f4e67e23eda4cd3ad.tar.gz
rust-42e5d451b7c3aacf6e6a589f4e67e23eda4cd3ad.zip
rustdoc: Change the header scheme so that all mods are h2, fns h3
Diffstat (limited to 'src')
-rw-r--r--src/rustdoc/gen.rs36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/rustdoc/gen.rs b/src/rustdoc/gen.rs
index 160576617d4..6c42c476b2f 100644
--- a/src/rustdoc/gen.rs
+++ b/src/rustdoc/gen.rs
@@ -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);