From 377316d8f607aeb4dda448abb14c8169adfba770 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 15 Jan 2012 14:39:09 -0800 Subject: [PATCH] rustdoc: Add parse::from_str for testing purposes --- src/rustdoc/rustdoc.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rustdoc/rustdoc.rs b/src/rustdoc/rustdoc.rs index abcc5cb6358..c71b3493e25 100755 --- a/src/rustdoc/rustdoc.rs +++ b/src/rustdoc/rustdoc.rs @@ -178,14 +178,26 @@ fn doc_header(rd: rustdoc, name: str) { } mod parse { - fn from_file(file: str) -> @ast::crate { + export from_file, from_str; + + fn new_parse_sess() -> parser::parse_sess { let cm = codemap::new_codemap(); let sess = @{ cm: cm, mutable next_id: 0, diagnostic: diagnostic::mk_handler(cm, none) }; - parser::parse_crate_from_source_file(file, [], sess) + ret sess; + } + + fn from_file(file: str) -> @ast::crate { + parser::parse_crate_from_source_file( + file, [], new_parse_sess()) + } + + fn from_str(source: str) -> @ast::crate { + parser::parse_crate_from_source_str( + "-", source, [], new_parse_sess()) } }