@@ -334,134 +334,6 @@ impl AllTypes {
334334 }
335335}
336336
337- #[ derive( Debug ) ]
338- enum Setting {
339- Section {
340- description : & ' static str ,
341- sub_settings : Vec < Setting > ,
342- } ,
343- Toggle {
344- js_data_name : & ' static str ,
345- description : & ' static str ,
346- default_value : bool ,
347- } ,
348- Select {
349- js_data_name : & ' static str ,
350- description : & ' static str ,
351- default_value : & ' static str ,
352- options : Vec < String > ,
353- } ,
354- }
355-
356- impl Setting {
357- fn display ( & self , root_path : & str , suffix : & str ) -> String {
358- match * self {
359- Setting :: Section { description, ref sub_settings } => format ! (
360- "<div class=\" setting-line\" >\
361- <div class=\" title\" >{}</div>\
362- <div class=\" sub-settings\" >{}</div>
363- </div>" ,
364- description,
365- sub_settings. iter( ) . map( |s| s. display( root_path, suffix) ) . collect:: <String >( )
366- ) ,
367- Setting :: Toggle { js_data_name, description, default_value } => format ! (
368- "<div class=\" setting-line\" >\
369- <label class=\" toggle\" >\
370- <input type=\" checkbox\" id=\" {}\" {}>\
371- <span class=\" slider\" ></span>\
372- </label>\
373- <div>{}</div>\
374- </div>",
375- js_data_name,
376- if default_value { " checked" } else { "" } ,
377- description,
378- ) ,
379- Setting :: Select { js_data_name, description, default_value, ref options } => format ! (
380- "<div class=\" setting-line\" ><div class=\" radio-line\" id=\" {}\" ><span class=\" setting-name\" >{}</span><div class=\" choices\" >{}</div></div></div>" ,
381- js_data_name,
382- description,
383- options
384- . iter( )
385- . map( |opt| format!(
386- "<label for=\" {js_data_name}-{name}\" class=\" choice\" >
387- <input type=\" radio\" name=\" {js_data_name}\" id=\" {js_data_name}-{name}\" value=\" {name}\" {checked}>\
388- {name}\
389- </label>",
390- js_data_name = js_data_name,
391- name = opt,
392- checked = if opt == default_value { "checked" } else { "" } ,
393- ) )
394- . collect:: <String >( ) ,
395- ) ,
396- }
397- }
398- }
399-
400- impl From < ( & ' static str , & ' static str , bool ) > for Setting {
401- fn from ( values : ( & ' static str , & ' static str , bool ) ) -> Setting {
402- Setting :: Toggle { js_data_name : values. 0 , description : values. 1 , default_value : values. 2 }
403- }
404- }
405-
406- impl < T : Into < Setting > > From < ( & ' static str , Vec < T > ) > for Setting {
407- fn from ( values : ( & ' static str , Vec < T > ) ) -> Setting {
408- Setting :: Section {
409- description : values. 0 ,
410- sub_settings : values. 1 . into_iter ( ) . map ( |v| v. into ( ) ) . collect :: < Vec < _ > > ( ) ,
411- }
412- }
413- }
414-
415- fn settings ( root_path : & str , suffix : & str , theme_names : Vec < String > ) -> Result < String , Error > {
416- // (id, explanation, default value)
417- let settings: & [ Setting ] = & [
418- Setting :: from ( ( "use-system-theme" , "Use system theme" , true ) ) ,
419- Setting :: Select {
420- js_data_name : "theme" ,
421- description : "Theme" ,
422- default_value : "light" ,
423- options : theme_names. clone ( ) ,
424- } ,
425- Setting :: Select {
426- js_data_name : "preferred-light-theme" ,
427- description : "Preferred light theme" ,
428- default_value : "light" ,
429- options : theme_names. clone ( ) ,
430- } ,
431- Setting :: Select {
432- js_data_name : "preferred-dark-theme" ,
433- description : "Preferred dark theme" ,
434- default_value : "dark" ,
435- options : theme_names,
436- } ,
437- ( "auto-hide-large-items" , "Auto-hide item contents for large items." , true ) . into ( ) ,
438- ( "auto-hide-method-docs" , "Auto-hide item methods' documentation" , false ) . into ( ) ,
439- ( "auto-hide-trait-implementations" , "Auto-hide trait implementation documentation" , false )
440- . into ( ) ,
441- ( "go-to-only-result" , "Directly go to item in search if there is only one result" , false )
442- . into ( ) ,
443- ( "line-numbers" , "Show line numbers on code examples" , false ) . into ( ) ,
444- ( "disable-shortcuts" , "Disable keyboard shortcuts" , false ) . into ( ) ,
445- ] ;
446-
447- Ok ( format ! (
448- "<div class=\" main-heading\" >
449- <h1 class=\" fqn\" >\
450- <span class=\" in-band\" >Rustdoc settings</span>\
451- </h1>\
452- <span class=\" out-of-band\" >\
453- <a id=\" back\" href=\" javascript:void(0)\" >Back</a>\
454- </span>\
455- </div>\
456- <div class=\" settings\" >{}</div>\
457- <link rel=\" stylesheet\" href=\" {root_path}settings{suffix}.css\" >\
458- <script src=\" {root_path}settings{suffix}.js\" ></script>",
459- settings. iter( ) . map( |s| s. display( root_path, suffix) ) . collect:: <String >( ) ,
460- root_path = root_path,
461- suffix = suffix
462- ) )
463- }
464-
465337fn scrape_examples_help ( shared : & SharedContext < ' _ > ) -> String {
466338 let mut content = SCRAPE_EXAMPLES_HELP_MD . to_owned ( ) ;
467339 content. push_str ( & format ! (
0 commit comments