@@ -119,6 +119,9 @@ pub struct SharedContext {
119119 /// The base-URL of the issue tracker for when an item has been tagged with
120120 /// an issue number.
121121 pub issue_tracker_base_url : Option < String > ,
122+ /// The given user css file which allow to customize the generated
123+ /// documentation theme.
124+ pub css_file_extension : Option < PathBuf > ,
122125}
123126
124127/// Indicates where an external crate can be found.
@@ -411,7 +414,8 @@ pub fn derive_id(candidate: String) -> String {
411414pub fn run ( mut krate : clean:: Crate ,
412415 external_html : & ExternalHtml ,
413416 dst : PathBuf ,
414- passes : HashSet < String > ) -> Result < ( ) , Error > {
417+ passes : HashSet < String > ,
418+ css_file_extension : Option < PathBuf > ) -> Result < ( ) , Error > {
415419 let src_root = match krate. src . parent ( ) {
416420 Some ( p) => p. to_path_buf ( ) ,
417421 None => PathBuf :: new ( ) ,
@@ -429,6 +433,11 @@ pub fn run(mut krate: clean::Crate,
429433 krate : krate. name . clone ( ) ,
430434 playground_url : "" . to_string ( ) ,
431435 } ,
436+ include_sources : true ,
437+ local_sources : HashMap :: new ( ) ,
438+ render_redirect_pages : false ,
439+ issue_tracker_base_url : None ,
440+ css_file_extension : css_file_extension,
432441 } ;
433442
434443 // Crawl the crate attributes looking for attributes which control how we're
@@ -637,6 +646,7 @@ fn write_shared(cx: &Context,
637646
638647 // Add all the static files. These may already exist, but we just
639648 // overwrite them anyway to make sure that they're fresh and up-to-date.
649+
640650 write ( cx. dst . join ( "jquery.js" ) ,
641651 include_bytes ! ( "static/jquery-2.1.4.min.js" ) ) ?;
642652 write ( cx. dst . join ( "main.js" ) ,
@@ -647,6 +657,17 @@ fn write_shared(cx: &Context,
647657 include_bytes ! ( "static/rustdoc.css" ) ) ?;
648658 write ( cx. dst . join ( "main.css" ) ,
649659 include_bytes ! ( "static/styles/main.css" ) ) ?;
660+ if let Some ( ref css) = cx. css_file_extension {
661+ let mut content = String :: new ( ) ;
662+ let css = css. as_path ( ) ;
663+ let mut f = try_err ! ( File :: open( css) , css) ;
664+
665+ try_err ! ( f. read_to_string( & mut content) , css) ;
666+ let css = cx. dst . join ( "theme.css" ) ;
667+ let css = css. as_path ( ) ;
668+ let mut f = try_err ! ( File :: create( css) , css) ;
669+ try_err ! ( write!( f, "{}" , & content) , css) ;
670+ }
650671 write ( cx. dst . join ( "normalize.css" ) ,
651672 include_bytes ! ( "static/normalize.css" ) ) ?;
652673 write ( cx. dst . join ( "FiraSans-Regular.woff" ) ,
@@ -931,8 +952,9 @@ impl<'a> SourceCollector<'a> {
931952 description : & desc,
932953 keywords : BASIC_KEYWORDS ,
933954 } ;
934- layout:: render ( & mut w, & self . scx . layout ,
935- & page, & ( "" ) , & Source ( contents) ) ?;
955+ layout:: render ( & mut w, & self . cx . layout ,
956+ & page, & ( "" ) , & Source ( contents) ,
957+ self . cx . css_file_extension . is_some ( ) ) ?;
936958 w. flush ( ) ?;
937959 self . scx . local_sources . insert ( p, href) ;
938960 Ok ( ( ) )
@@ -1294,8 +1316,8 @@ impl Context {
12941316 if !cx. render_redirect_pages {
12951317 layout:: render ( & mut writer, & cx. shared . layout , & page,
12961318 & Sidebar { cx : cx, item : it } ,
1297- & Item { cx : cx, item : it } ) ? ;
1298-
1319+ & Item { cx : cx, item : it } ,
1320+ cx . css_file_extension . is_some ( ) ) ? ;
12991321 } else {
13001322 let mut url = repeat ( "../" ) . take ( cx. current . len ( ) )
13011323 . collect :: < String > ( ) ;
0 commit comments