@@ -115,6 +115,9 @@ pub struct Context {
115115 /// The base-URL of the issue tracker for when an item has been tagged with
116116 /// an issue number.
117117 pub issue_tracker_base_url : Option < String > ,
118+ /// The given user css file which allow to customize the generated
119+ /// documentation theme.
120+ pub css_file_extension : Option < PathBuf > ,
118121}
119122
120123/// Indicates where an external crate can be found.
@@ -404,7 +407,8 @@ pub fn derive_id(candidate: String) -> String {
404407pub fn run ( mut krate : clean:: Crate ,
405408 external_html : & ExternalHtml ,
406409 dst : PathBuf ,
407- passes : HashSet < String > ) -> Result < ( ) , Error > {
410+ passes : HashSet < String > ,
411+ css_file_extension : Option < PathBuf > ) -> Result < ( ) , Error > {
408412 let src_root = match krate. src . parent ( ) {
409413 Some ( p) => p. to_path_buf ( ) ,
410414 None => PathBuf :: new ( ) ,
@@ -426,6 +430,7 @@ pub fn run(mut krate: clean::Crate,
426430 local_sources : HashMap :: new ( ) ,
427431 render_redirect_pages : false ,
428432 issue_tracker_base_url : None ,
433+ css_file_extension : css_file_extension,
429434 } ;
430435
431436 try_err ! ( mkdir( & cx. dst) , & cx. dst) ;
@@ -639,6 +644,17 @@ fn write_shared(cx: &Context,
639644 include_bytes ! ( "static/rustdoc.css" ) ) ) ;
640645 try!( write ( cx. dst . join ( "main.css" ) ,
641646 include_bytes ! ( "static/styles/main.css" ) ) ) ;
647+ if let Some ( ref css) = cx. css_file_extension {
648+ let mut content = String :: new ( ) ;
649+ let css = css. as_path ( ) ;
650+ let mut f = try_err ! ( File :: open( css) , css) ;
651+
652+ try_err ! ( f. read_to_string( & mut content) , css) ;
653+ let css = cx. dst . join ( "theme.css" ) ;
654+ let css = css. as_path ( ) ;
655+ let mut f = try_err ! ( File :: create( css) , css) ;
656+ try_err ! ( write!( f, "{}" , & content) , css) ;
657+ }
642658 try!( write ( cx. dst . join ( "normalize.css" ) ,
643659 include_bytes ! ( "static/normalize.css" ) ) ) ;
644660 try!( write ( cx. dst . join ( "FiraSans-Regular.woff" ) ,
@@ -925,7 +941,8 @@ impl<'a> SourceCollector<'a> {
925941 keywords : BASIC_KEYWORDS ,
926942 } ;
927943 try!( layout:: render ( & mut w, & self . cx . layout ,
928- & page, & ( "" ) , & Source ( contents) ) ) ;
944+ & page, & ( "" ) , & Source ( contents) ,
945+ self . cx . css_file_extension . is_some ( ) ) ) ;
929946 try!( w. flush ( ) ) ;
930947 self . cx . local_sources . insert ( p, href) ;
931948 Ok ( ( ) )
@@ -1291,7 +1308,8 @@ impl Context {
12911308 if !cx. render_redirect_pages {
12921309 try!( layout:: render ( & mut writer, & cx. layout , & page,
12931310 & Sidebar { cx : cx, item : it } ,
1294- & Item { cx : cx, item : it } ) ) ;
1311+ & Item { cx : cx, item : it } ,
1312+ cx. css_file_extension . is_some ( ) ) ) ;
12951313 } else {
12961314 let mut url = repeat ( "../" ) . take ( cx. current . len ( ) )
12971315 . collect :: < String > ( ) ;
0 commit comments