@@ -115,6 +115,9 @@ pub struct Context {
115
115
/// The base-URL of the issue tracker for when an item has been tagged with
116
116
/// an issue number.
117
117
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 > ,
118
121
}
119
122
120
123
/// Indicates where an external crate can be found.
@@ -404,7 +407,8 @@ pub fn derive_id(candidate: String) -> String {
404
407
pub fn run ( mut krate : clean:: Crate ,
405
408
external_html : & ExternalHtml ,
406
409
dst : PathBuf ,
407
- passes : HashSet < String > ) -> Result < ( ) , Error > {
410
+ passes : HashSet < String > ,
411
+ css_file_extension : Option < PathBuf > ) -> Result < ( ) , Error > {
408
412
let src_root = match krate. src . parent ( ) {
409
413
Some ( p) => p. to_path_buf ( ) ,
410
414
None => PathBuf :: new ( ) ,
@@ -426,6 +430,7 @@ pub fn run(mut krate: clean::Crate,
426
430
local_sources : HashMap :: new ( ) ,
427
431
render_redirect_pages : false ,
428
432
issue_tracker_base_url : None ,
433
+ css_file_extension : css_file_extension,
429
434
} ;
430
435
431
436
try_err ! ( mkdir( & cx. dst) , & cx. dst) ;
@@ -639,6 +644,17 @@ fn write_shared(cx: &Context,
639
644
include_bytes ! ( "static/rustdoc.css" ) ) ) ;
640
645
try!( write ( cx. dst . join ( "main.css" ) ,
641
646
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
+ }
642
658
try!( write ( cx. dst . join ( "normalize.css" ) ,
643
659
include_bytes ! ( "static/normalize.css" ) ) ) ;
644
660
try!( write ( cx. dst . join ( "FiraSans-Regular.woff" ) ,
@@ -925,7 +941,8 @@ impl<'a> SourceCollector<'a> {
925
941
keywords : BASIC_KEYWORDS ,
926
942
} ;
927
943
try!( layout:: render ( & mut w, & self . cx . layout ,
928
- & page, & ( "" ) , & Source ( contents) ) ) ;
944
+ & page, & ( "" ) , & Source ( contents) ,
945
+ self . cx . css_file_extension . is_some ( ) ) ) ;
929
946
try!( w. flush ( ) ) ;
930
947
self . cx . local_sources . insert ( p, href) ;
931
948
Ok ( ( ) )
@@ -1291,7 +1308,8 @@ impl Context {
1291
1308
if !cx. render_redirect_pages {
1292
1309
try!( layout:: render ( & mut writer, & cx. layout , & page,
1293
1310
& Sidebar { cx : cx, item : it } ,
1294
- & Item { cx : cx, item : it } ) ) ;
1311
+ & Item { cx : cx, item : it } ,
1312
+ cx. css_file_extension . is_some ( ) ) ) ;
1295
1313
} else {
1296
1314
let mut url = repeat ( "../" ) . take ( cx. current . len ( ) )
1297
1315
. collect :: < String > ( ) ;
0 commit comments