Skip to content

Commit f161352

Browse files
committed
---
yaml --- r: 7471 b: refs/heads/master c: 42e5d45 h: refs/heads/master i: 7469: add9ac0 7467: f4b3f86 7463: 07bb44f 7455: e4655e5 v: v3
1 parent 3f41fbe commit f161352

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: a5e0f037be17204c640e2941e576a9dca09efc90
2+
refs/heads/master: 42e5d451b7c3aacf6e6a589f4e67e23eda4cd3ad

trunk/src/rustdoc/gen.rs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,37 @@ fn mk_pass(
1818
}
1919

2020
type ctxt = {
21-
w: io::writer,
22-
mutable depth: uint
21+
w: io::writer
2322
};
2423

2524
fn write_markdown(
2625
doc: doc::cratedoc,
2726
writer: io::writer
2827
) {
2928
let ctxt = {
30-
w: writer,
31-
mutable depth: 1u
29+
w: writer
3230
};
3331

3432
write_crate(ctxt, doc);
3533
}
3634

37-
fn write_header(ctxt: ctxt, title: str) {
38-
let hashes = str::from_chars(vec::init_elt('#', ctxt.depth));
39-
ctxt.w.write_line(#fmt("%s %s", hashes, title));
40-
ctxt.w.write_line("");
35+
tag hlvl {
36+
h1 = 1;
37+
h2 = 2;
38+
h3 = 3;
4139
}
4240

43-
fn subsection(ctxt: ctxt, f: fn&()) {
44-
ctxt.depth += 1u;
45-
f();
46-
ctxt.depth -= 1u;
41+
fn write_header(ctxt: ctxt, lvl: hlvl, title: str) {
42+
let hashes = str::from_chars(vec::init_elt('#', lvl as uint));
43+
ctxt.w.write_line(#fmt("%s %s", hashes, title));
44+
ctxt.w.write_line("");
4745
}
4846

4947
fn write_crate(
5048
ctxt: ctxt,
5149
doc: doc::cratedoc
5250
) {
53-
write_header(ctxt, #fmt("Crate %s", doc.topmod.name));
51+
write_header(ctxt, h1, #fmt("Crate %s", doc.topmod.name));
5452
write_top_module(ctxt, doc.topmod);
5553
}
5654

@@ -65,7 +63,7 @@ fn write_mod(
6563
ctxt: ctxt,
6664
moddoc: doc::moddoc
6765
) {
68-
write_header(ctxt, #fmt("Module `%s`", moddoc.name));
66+
write_header(ctxt, h2, #fmt("Module `%s`", moddoc.name));
6967
write_mod_contents(ctxt, moddoc);
7068
}
7169

@@ -77,15 +75,11 @@ fn write_mod_contents(
7775
write_desc(ctxt, doc.desc);
7876

7977
for fndoc in *doc.fns {
80-
subsection(ctxt) {||
81-
write_fn(ctxt, fndoc);
82-
}
78+
write_fn(ctxt, fndoc);
8379
}
8480

8581
for moddoc in *doc.mods {
86-
subsection(ctxt) {||
87-
write_mod(ctxt, moddoc);
88-
}
82+
write_mod(ctxt, moddoc);
8983
}
9084
}
9185

@@ -105,7 +99,7 @@ fn write_fn(
10599
ctxt: ctxt,
106100
doc: doc::fndoc
107101
) {
108-
write_header(ctxt, #fmt("Function `%s`", doc.name));
102+
write_header(ctxt, h3, #fmt("Function `%s`", doc.name));
109103
write_brief(ctxt, doc.brief);
110104
write_desc(ctxt, doc.desc);
111105
write_args(ctxt, doc.args);

0 commit comments

Comments
 (0)