@@ -32,13 +32,16 @@ use std::io::{File, MemWriter};
3232use std:: str;
3333use std:: gc:: Gc ;
3434use serialize:: { json, Decodable , Encodable } ;
35+ use externalfiles:: ExternalHtml ;
3536
3637// reexported from `clean` so it can be easily updated with the mod itself
3738pub use clean:: SCHEMA_VERSION ;
3839
3940pub mod clean;
4041pub mod core;
4142pub mod doctree;
43+ #[ macro_escape]
44+ pub mod externalfiles;
4245pub mod fold;
4346pub mod html {
4447 pub mod highlight;
@@ -113,16 +116,17 @@ pub fn opts() -> Vec<getopts::OptGroup> {
113116 "ARGS" ) ,
114117 optmulti( "" , "markdown-css" , "CSS files to include via <link> in a rendered Markdown file" ,
115118 "FILES" ) ,
116- optmulti( "" , "markdown-in-header" ,
117- "files to include inline in the <head> section of a rendered Markdown file" ,
119+ optmulti( "" , "html-in-header" ,
120+ "files to include inline in the <head> section of a rendered Markdown file \
121+ or generated documentation",
118122 "FILES" ) ,
119- optmulti( "" , "markdown -before-content" ,
123+ optmulti( "" , "html -before-content" ,
120124 "files to include inline between <body> and the content of a rendered \
121- Markdown file",
125+ Markdown file or generated documentation ",
122126 "FILES" ) ,
123- optmulti( "" , "markdown -after-content" ,
127+ optmulti( "" , "html -after-content" ,
124128 "files to include inline between the content and </body> of a rendered \
125- Markdown file",
129+ Markdown file or generated documentation ",
126130 "FILES" ) ,
127131 optopt( "" , "markdown-playground-url" ,
128132 "URL to send code snippets to" , "URL" )
@@ -179,6 +183,14 @@ pub fn main_args(args: &[String]) -> int {
179183 let output = matches. opt_str ( "o" ) . map ( |s| Path :: new ( s) ) ;
180184 let cfgs = matches. opt_strs ( "cfg" ) ;
181185
186+ let external_html = match ExternalHtml :: load (
187+ matches. opt_strs ( "html-in-header" ) . as_slice ( ) ,
188+ matches. opt_strs ( "html-before-content" ) . as_slice ( ) ,
189+ matches. opt_strs ( "html-after-content" ) . as_slice ( ) ) {
190+ Some ( eh) => eh,
191+ None => return 3
192+ } ;
193+
182194 match ( should_test, markdown_input) {
183195 ( true , true ) => {
184196 return markdown:: test ( input, libs, test_args)
@@ -187,7 +199,7 @@ pub fn main_args(args: &[String]) -> int {
187199 return test:: run ( input, cfgs, libs, test_args)
188200 }
189201 ( false , true ) => return markdown:: render ( input, output. unwrap_or ( Path :: new ( "doc" ) ) ,
190- & matches) ,
202+ & matches, & external_html ) ,
191203 ( false , false ) => { }
192204 }
193205
@@ -215,7 +227,7 @@ pub fn main_args(args: &[String]) -> int {
215227 let started = time:: precise_time_ns ( ) ;
216228 match matches. opt_str ( "w" ) . as_ref ( ) . map ( |s| s. as_slice ( ) ) {
217229 Some ( "html" ) | None => {
218- match html:: render:: run ( krate, output. unwrap_or ( Path :: new ( "doc" ) ) ) {
230+ match html:: render:: run ( krate, & external_html , output. unwrap_or ( Path :: new ( "doc" ) ) ) {
219231 Ok ( ( ) ) => { }
220232 Err ( e) => fail ! ( "failed to generate documentation: {}" , e) ,
221233 }
0 commit comments