Skip to content

Commit eb0f6b4

Browse files
committed
---
yaml --- r: 7293 b: refs/heads/master c: 0e65ddf h: refs/heads/master i: 7291: 277030c v: v3
1 parent a8ae057 commit eb0f6b4

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
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: e4d553c534e80442bed5ce63f74ca67112035d08
2+
refs/heads/master: 0e65ddfaea1c25c0fb2f20a2d28ed782c1dff369

trunk/src/rustdoc/rustdoc.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,34 +177,40 @@ fn doc_header(rd: rustdoc, name: str) {
177177
rd.w.write_line("# Crate " + name);
178178
}
179179

180+
mod parse {
181+
fn from_file(file: str) -> @ast::crate {
182+
let cm = codemap::new_codemap();
183+
let sess = @{
184+
cm: cm,
185+
mutable next_id: 0,
186+
diagnostic: diagnostic::mk_handler(cm, none)
187+
};
188+
parser::parse_crate_from_source_file(file, [], sess)
189+
}
190+
}
191+
180192
#[doc(
181193
brief = "Main function.",
182194
desc = "Command-line arguments:
183195
184196
* argv[1]: crate file name",
185197
args(argv = "Command-line arguments.")
186198
)]
187-
188199
fn main(argv: [str]) {
189200

190-
let w = io::stdout();
191-
192201
if vec::len(argv) != 2u {
193-
w.write_str(#fmt("usage: %s <input>\n", argv[0]));
202+
io::println(#fmt("usage: %s <input>", argv[0]));
194203
ret;
195204
}
196205

197-
let cm = codemap::new_codemap();
198-
let sess = @{
199-
cm: cm,
200-
mutable next_id: 0,
201-
diagnostic: diagnostic::mk_handler(cm, none)
202-
};
206+
let crate = parse::from_file(argv[1]);
207+
208+
let w = io::stdout();
203209
let rd = { ps: pprust::rust_printer(w), w: w };
204210
doc_header(rd, argv[1]);
205-
let p = parser::parse_crate_from_source_file(argv[1], [], sess);
211+
206212
let v = visit::mk_simple_visitor(@{
207213
visit_item: bind doc_item(rd, _)
208214
with *visit::default_simple_visitor()});
209-
visit::visit_crate(*p, (), v);
215+
visit::visit_crate(*crate, (), v);
210216
}

0 commit comments

Comments
 (0)