@@ -64,7 +64,6 @@ use serde::ser::SerializeSeq;
64
64
use serde:: { Serialize , Serializer } ;
65
65
66
66
use crate :: clean:: { self , ItemId , RenderedLink , SelfTy } ;
67
- use crate :: docfs:: PathError ;
68
67
use crate :: error:: Error ;
69
68
use crate :: formats:: cache:: Cache ;
70
69
use crate :: formats:: item_type:: ItemType ;
@@ -173,8 +172,12 @@ impl Serialize for TypeWithKind {
173
172
crate struct StylePath {
174
173
/// The path to the theme
175
174
crate path : PathBuf ,
176
- /// What the `disabled` attribute should be set to in the HTML tag
177
- crate disabled : bool ,
175
+ }
176
+
177
+ impl StylePath {
178
+ pub fn basename ( & self ) -> Result < String , Error > {
179
+ Ok ( try_none ! ( try_none!( self . path. file_stem( ) , & self . path) . to_str( ) , & self . path) . to_string ( ) )
180
+ }
178
181
}
179
182
180
183
fn write_srclink ( cx : & Context < ' _ > , item : & clean:: Item , buf : & mut Buffer ) {
@@ -353,7 +356,7 @@ enum Setting {
353
356
js_data_name : & ' static str ,
354
357
description : & ' static str ,
355
358
default_value : & ' static str ,
356
- options : Vec < ( String , String ) > ,
359
+ options : Vec < String > ,
357
360
} ,
358
361
}
359
362
@@ -393,10 +396,9 @@ impl Setting {
393
396
options
394
397
. iter( )
395
398
. map( |opt| format!(
396
- "<option value=\" {}\" {}>{}</option>" ,
397
- opt. 0 ,
398
- if opt. 0 == default_value { "selected" } else { "" } ,
399
- opt. 1 ,
399
+ "<option value=\" {name}\" {}>{name}</option>" ,
400
+ if opt == default_value { "selected" } else { "" } ,
401
+ name = opt,
400
402
) )
401
403
. collect:: <String >( ) ,
402
404
root_path,
@@ -421,18 +423,7 @@ impl<T: Into<Setting>> From<(&'static str, Vec<T>)> for Setting {
421
423
}
422
424
}
423
425
424
- fn settings ( root_path : & str , suffix : & str , themes : & [ StylePath ] ) -> Result < String , Error > {
425
- let theme_names: Vec < ( String , String ) > = themes
426
- . iter ( )
427
- . map ( |entry| {
428
- let theme =
429
- try_none ! ( try_none!( entry. path. file_stem( ) , & entry. path) . to_str( ) , & entry. path)
430
- . to_string ( ) ;
431
-
432
- Ok ( ( theme. clone ( ) , theme) )
433
- } )
434
- . collect :: < Result < _ , Error > > ( ) ?;
435
-
426
+ fn settings ( root_path : & str , suffix : & str , theme_names : Vec < String > ) -> Result < String , Error > {
436
427
// (id, explanation, default value)
437
428
let settings: & [ Setting ] = & [
438
429
(
@@ -469,10 +460,11 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result<Strin
469
460
<span class=\" in-band\" >Rustdoc settings</span>\
470
461
</h1>\
471
462
<div class=\" settings\" >{}</div>\
472
- <script src=\" {}settings{}.js\" ></script>",
463
+ <link rel=\" stylesheet\" href=\" {root_path}settings{suffix}.css\" >\
464
+ <script src=\" {root_path}settings{suffix}.js\" ></script>",
473
465
settings. iter( ) . map( |s| s. display( root_path, suffix) ) . collect:: <String >( ) ,
474
- root_path,
475
- suffix
466
+ root_path = root_path ,
467
+ suffix = suffix
476
468
) )
477
469
}
478
470
0 commit comments