@@ -166,7 +166,6 @@ struct Context {
166
166
/// The map used to ensure all generated 'id=' attributes are unique.
167
167
id_map : Rc < RefCell < IdMap > > ,
168
168
pub shared : Arc < SharedContext > ,
169
- playground : Option < markdown:: Playground > ,
170
169
}
171
170
172
171
crate struct SharedContext {
@@ -208,6 +207,7 @@ crate struct SharedContext {
208
207
/// The default edition used to parse doctests.
209
208
pub edition : Edition ,
210
209
pub codes : ErrorCodes ,
210
+ playground : Option < markdown:: Playground > ,
211
211
}
212
212
213
213
impl SharedContext {
@@ -518,31 +518,6 @@ pub fn run(mut krate: clean::Crate,
518
518
_ => PathBuf :: new ( ) ,
519
519
} ;
520
520
let mut errors = Arc :: new ( ErrorStorage :: new ( ) ) ;
521
- let mut scx = SharedContext {
522
- collapsed : krate. collapsed ,
523
- src_root,
524
- include_sources : true ,
525
- local_sources : Default :: default ( ) ,
526
- issue_tracker_base_url : None ,
527
- layout : layout:: Layout {
528
- logo : String :: new ( ) ,
529
- favicon : String :: new ( ) ,
530
- external_html,
531
- krate : krate. name . clone ( ) ,
532
- css_file_extension : extension_css,
533
- generate_search_filter,
534
- } ,
535
- created_dirs : Default :: default ( ) ,
536
- sort_modules_alphabetically,
537
- themes,
538
- resource_suffix,
539
- static_root_path,
540
- generate_redirect_pages,
541
- fs : DocFS :: new ( & errors) ,
542
- edition,
543
- codes : ErrorCodes :: from ( UnstableFeatures :: from_environment ( ) . is_nightly_build ( ) ) ,
544
- } ;
545
-
546
521
// If user passed in `--playground-url` arg, we fill in crate name here
547
522
let mut playground = None ;
548
523
if let Some ( url) = playground_url {
@@ -551,17 +526,27 @@ pub fn run(mut krate: clean::Crate,
551
526
url,
552
527
} ) ;
553
528
}
529
+ let mut layout = layout:: Layout {
530
+ logo : String :: new ( ) ,
531
+ favicon : String :: new ( ) ,
532
+ external_html,
533
+ krate : krate. name . clone ( ) ,
534
+ css_file_extension : extension_css,
535
+ generate_search_filter,
536
+ } ;
537
+ let mut issue_tracker_base_url = None ;
538
+ let mut include_sources = true ;
554
539
555
540
// Crawl the crate attributes looking for attributes which control how we're
556
541
// going to emit HTML
557
542
if let Some ( attrs) = krate. module . as_ref ( ) . map ( |m| & m. attrs ) {
558
543
for attr in attrs. lists ( sym:: doc) {
559
544
match ( attr. name_or_empty ( ) , attr. value_str ( ) ) {
560
545
( sym:: html_favicon_url, Some ( s) ) => {
561
- scx . layout . favicon = s. to_string ( ) ;
546
+ layout. favicon = s. to_string ( ) ;
562
547
}
563
548
( sym:: html_logo_url, Some ( s) ) => {
564
- scx . layout . logo = s. to_string ( ) ;
549
+ layout. logo = s. to_string ( ) ;
565
550
}
566
551
( sym:: html_playground_url, Some ( s) ) => {
567
552
playground = Some ( markdown:: Playground {
@@ -570,15 +555,34 @@ pub fn run(mut krate: clean::Crate,
570
555
} ) ;
571
556
}
572
557
( sym:: issue_tracker_base_url, Some ( s) ) => {
573
- scx . issue_tracker_base_url = Some ( s. to_string ( ) ) ;
558
+ issue_tracker_base_url = Some ( s. to_string ( ) ) ;
574
559
}
575
560
( sym:: html_no_source, None ) if attr. is_word ( ) => {
576
- scx . include_sources = false ;
561
+ include_sources = false ;
577
562
}
578
563
_ => { }
579
564
}
580
565
}
581
566
}
567
+ let mut scx = SharedContext {
568
+ collapsed : krate. collapsed ,
569
+ src_root,
570
+ include_sources,
571
+ local_sources : Default :: default ( ) ,
572
+ issue_tracker_base_url,
573
+ layout,
574
+ created_dirs : Default :: default ( ) ,
575
+ sort_modules_alphabetically,
576
+ themes,
577
+ resource_suffix,
578
+ static_root_path,
579
+ generate_redirect_pages,
580
+ fs : DocFS :: new ( & errors) ,
581
+ edition,
582
+ codes : ErrorCodes :: from ( UnstableFeatures :: from_environment ( ) . is_nightly_build ( ) ) ,
583
+ playground,
584
+ } ;
585
+
582
586
let dst = output;
583
587
scx. ensure_dir ( & dst) ?;
584
588
krate = sources:: render ( & dst, & mut scx, krate) ?;
@@ -588,7 +592,6 @@ pub fn run(mut krate: clean::Crate,
588
592
render_redirect_pages : false ,
589
593
id_map : Rc :: new ( RefCell :: new ( id_map) ) ,
590
594
shared : Arc :: new ( scx) ,
591
- playground,
592
595
} ;
593
596
594
597
// Crawl the crate to build various caches used for the output
@@ -2353,7 +2356,7 @@ fn render_markdown(
2353
2356
if is_hidden { " hidden" } else { "" } ,
2354
2357
prefix,
2355
2358
Markdown ( md_text, & links, & mut ids,
2356
- cx. shared. codes, cx. shared. edition, & cx. playground) . to_string( ) )
2359
+ cx. shared. codes, cx. shared. edition, & cx. shared . playground) . to_string( ) )
2357
2360
}
2358
2361
2359
2362
fn document_short (
@@ -2711,7 +2714,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
2711
2714
if let Some ( note) = note {
2712
2715
let mut ids = cx. id_map . borrow_mut ( ) ;
2713
2716
let html = MarkdownHtml (
2714
- & note, & mut ids, error_codes, cx. shared . edition , & cx. playground ) ;
2717
+ & note, & mut ids, error_codes, cx. shared . edition , & cx. shared . playground ) ;
2715
2718
message. push_str ( & format ! ( ": {}" , html. to_string( ) ) ) ;
2716
2719
}
2717
2720
stability. push ( format ! ( "<div class='stab deprecated'>{}</div>" , message) ) ;
@@ -2765,7 +2768,7 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
2765
2768
& mut ids,
2766
2769
error_codes,
2767
2770
cx. shared. edition,
2768
- & cx. playground,
2771
+ & cx. shared . playground,
2769
2772
) . to_string( )
2770
2773
) ;
2771
2774
}
@@ -3961,7 +3964,7 @@ fn render_impl(w: &mut Buffer, cx: &Context, i: &Impl, link: AssocItemLink<'_>,
3961
3964
let mut ids = cx. id_map . borrow_mut ( ) ;
3962
3965
write ! ( w, "<div class='docblock'>{}</div>" ,
3963
3966
Markdown ( & * dox, & i. impl_item. links( ) , & mut ids,
3964
- cx. shared. codes, cx. shared. edition, & cx. playground) . to_string( ) ) ;
3967
+ cx. shared. codes, cx. shared. edition, & cx. shared . playground) . to_string( ) ) ;
3965
3968
}
3966
3969
}
3967
3970
0 commit comments