@@ -32,13 +32,16 @@ use std::io::{File, MemWriter};
32
32
use std:: str;
33
33
use std:: gc:: Gc ;
34
34
use serialize:: { json, Decodable , Encodable } ;
35
+ use externalfiles:: ExternalHtml ;
35
36
36
37
// reexported from `clean` so it can be easily updated with the mod itself
37
38
pub use clean:: SCHEMA_VERSION ;
38
39
39
40
pub mod clean;
40
41
pub mod core;
41
42
pub mod doctree;
43
+ #[ macro_escape]
44
+ pub mod externalfiles;
42
45
pub mod fold;
43
46
pub mod html {
44
47
pub mod highlight;
@@ -113,16 +116,17 @@ pub fn opts() -> Vec<getopts::OptGroup> {
113
116
"ARGS" ) ,
114
117
optmulti( "" , "markdown-css" , "CSS files to include via <link> in a rendered Markdown file" ,
115
118
"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",
118
122
"FILES" ) ,
119
- optmulti( "" , "markdown -before-content" ,
123
+ optmulti( "" , "html -before-content" ,
120
124
"files to include inline between <body> and the content of a rendered \
121
- Markdown file",
125
+ Markdown file or generated documentation ",
122
126
"FILES" ) ,
123
- optmulti( "" , "markdown -after-content" ,
127
+ optmulti( "" , "html -after-content" ,
124
128
"files to include inline between the content and </body> of a rendered \
125
- Markdown file",
129
+ Markdown file or generated documentation ",
126
130
"FILES" ) ,
127
131
optopt( "" , "markdown-playground-url" ,
128
132
"URL to send code snippets to" , "URL" )
@@ -179,6 +183,14 @@ pub fn main_args(args: &[String]) -> int {
179
183
let output = matches. opt_str ( "o" ) . map ( |s| Path :: new ( s) ) ;
180
184
let cfgs = matches. opt_strs ( "cfg" ) ;
181
185
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
+
182
194
match ( should_test, markdown_input) {
183
195
( true , true ) => {
184
196
return markdown:: test ( input, libs, test_args)
@@ -187,7 +199,7 @@ pub fn main_args(args: &[String]) -> int {
187
199
return test:: run ( input, cfgs, libs, test_args)
188
200
}
189
201
( false , true ) => return markdown:: render ( input, output. unwrap_or ( Path :: new ( "doc" ) ) ,
190
- & matches) ,
202
+ & matches, & external_html ) ,
191
203
( false , false ) => { }
192
204
}
193
205
@@ -215,7 +227,7 @@ pub fn main_args(args: &[String]) -> int {
215
227
let started = time:: precise_time_ns ( ) ;
216
228
match matches. opt_str ( "w" ) . as_ref ( ) . map ( |s| s. as_slice ( ) ) {
217
229
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" ) ) ) {
219
231
Ok ( ( ) ) => { }
220
232
Err ( e) => fail ! ( "failed to generate documentation: {}" , e) ,
221
233
}
0 commit comments