@@ -119,6 +119,9 @@ pub struct SharedContext {
119
119
/// The base-URL of the issue tracker for when an item has been tagged with
120
120
/// an issue number.
121
121
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 > ,
122
125
}
123
126
124
127
/// Indicates where an external crate can be found.
@@ -411,7 +414,8 @@ pub fn derive_id(candidate: String) -> String {
411
414
pub fn run ( mut krate : clean:: Crate ,
412
415
external_html : & ExternalHtml ,
413
416
dst : PathBuf ,
414
- passes : HashSet < String > ) -> Result < ( ) , Error > {
417
+ passes : HashSet < String > ,
418
+ css_file_extension : Option < PathBuf > ) -> Result < ( ) , Error > {
415
419
let src_root = match krate. src . parent ( ) {
416
420
Some ( p) => p. to_path_buf ( ) ,
417
421
None => PathBuf :: new ( ) ,
@@ -429,6 +433,11 @@ pub fn run(mut krate: clean::Crate,
429
433
krate : krate. name . clone ( ) ,
430
434
playground_url : "" . to_string ( ) ,
431
435
} ,
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,
432
441
} ;
433
442
434
443
// Crawl the crate attributes looking for attributes which control how we're
@@ -637,6 +646,7 @@ fn write_shared(cx: &Context,
637
646
638
647
// Add all the static files. These may already exist, but we just
639
648
// overwrite them anyway to make sure that they're fresh and up-to-date.
649
+
640
650
write ( cx. dst . join ( "jquery.js" ) ,
641
651
include_bytes ! ( "static/jquery-2.1.4.min.js" ) ) ?;
642
652
write ( cx. dst . join ( "main.js" ) ,
@@ -647,6 +657,17 @@ fn write_shared(cx: &Context,
647
657
include_bytes ! ( "static/rustdoc.css" ) ) ?;
648
658
write ( cx. dst . join ( "main.css" ) ,
649
659
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
+ }
650
671
write ( cx. dst . join ( "normalize.css" ) ,
651
672
include_bytes ! ( "static/normalize.css" ) ) ?;
652
673
write ( cx. dst . join ( "FiraSans-Regular.woff" ) ,
@@ -931,8 +952,9 @@ impl<'a> SourceCollector<'a> {
931
952
description : & desc,
932
953
keywords : BASIC_KEYWORDS ,
933
954
} ;
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 ( ) ) ?;
936
958
w. flush ( ) ?;
937
959
self . scx . local_sources . insert ( p, href) ;
938
960
Ok ( ( ) )
@@ -1294,8 +1316,8 @@ impl Context {
1294
1316
if !cx. render_redirect_pages {
1295
1317
layout:: render ( & mut writer, & cx. shared . layout , & page,
1296
1318
& 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 ( ) ) ? ;
1299
1321
} else {
1300
1322
let mut url = repeat ( "../" ) . take ( cx. current . len ( ) )
1301
1323
. collect :: < String > ( ) ;
0 commit comments