@@ -20,7 +20,7 @@ use super::{collect_spans_and_sources, scrape_examples_help, AllTypes, LinkFromS
20
20
use crate :: clean:: types:: ExternalLocation ;
21
21
use crate :: clean:: utils:: has_doc_flag;
22
22
use crate :: clean:: { self , ExternalCrate } ;
23
- use crate :: config:: { ModuleSorting , RenderOptions } ;
23
+ use crate :: config:: { ModuleSorting , RenderOptions , ShouldMerge } ;
24
24
use crate :: docfs:: { DocFS , PathError } ;
25
25
use crate :: error:: Error ;
26
26
use crate :: formats:: cache:: Cache ;
@@ -127,8 +127,10 @@ pub(crate) struct SharedContext<'tcx> {
127
127
pub ( crate ) span_correspondence_map : FxHashMap < rustc_span:: Span , LinkFromSrc > ,
128
128
/// The [`Cache`] used during rendering.
129
129
pub ( crate ) cache : Cache ,
130
-
131
130
pub ( crate ) call_locations : AllCallLocations ,
131
+ /// Controls whether we read / write to cci files in the doc root. Defaults read=true,
132
+ /// write=true
133
+ should_merge : ShouldMerge ,
132
134
}
133
135
134
136
impl SharedContext < ' _ > {
@@ -550,6 +552,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
550
552
span_correspondence_map : matches,
551
553
cache,
552
554
call_locations,
555
+ should_merge : options. should_merge ,
553
556
} ;
554
557
555
558
let dst = output;
@@ -637,92 +640,96 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
637
640
) ;
638
641
shared. fs . write ( final_file, v) ?;
639
642
640
- // Generating settings page.
641
- page. title = "Settings" ;
642
- page. description = "Settings of Rustdoc" ;
643
- page. root_path = "./" ;
644
- page. rust_logo = true ;
643
+ // if to avoid writing help, settings files to doc root unless we're on the final invocation
644
+ if shared. should_merge . write_rendered_cci {
645
+ // Generating settings page.
646
+ page. title = "Settings" ;
647
+ page. description = "Settings of Rustdoc" ;
648
+ page. root_path = "./" ;
649
+ page. rust_logo = true ;
645
650
646
- let sidebar = "<h2 class=\" location\" >Settings</h2><div class=\" sidebar-elems\" ></div>" ;
647
- let v = layout:: render (
648
- & shared. layout ,
649
- & page,
650
- sidebar,
651
- |buf : & mut Buffer | {
652
- write ! (
653
- buf,
654
- "<div class=\" main-heading\" >\
655
- <h1>Rustdoc settings</h1>\
656
- <span class=\" out-of-band\" >\
657
- <a id=\" back\" href=\" javascript:void(0)\" onclick=\" history.back();\" >\
658
- Back\
659
- </a>\
660
- </span>\
661
- </div>\
662
- <noscript>\
663
- <section>\
664
- You need to enable JavaScript be able to update your settings.\
665
- </section>\
666
- </noscript>\
667
- <script defer src=\" {static_root_path}{settings_js}\" ></script>",
668
- static_root_path = page. get_static_root_path( ) ,
669
- settings_js = static_files:: STATIC_FILES . settings_js,
670
- ) ;
671
- // Pre-load all theme CSS files, so that switching feels seamless.
672
- //
673
- // When loading settings.html as a popover, the equivalent HTML is
674
- // generated in main.js.
675
- for file in & shared. style_files {
676
- if let Ok ( theme) = file. basename ( ) {
677
- write ! (
678
- buf,
679
- "<link rel=\" preload\" href=\" {root_path}{theme}{suffix}.css\" \
680
- as=\" style\" >",
681
- root_path = page. static_root_path. unwrap_or( "" ) ,
682
- suffix = page. resource_suffix,
683
- ) ;
651
+ let sidebar = "<h2 class=\" location\" >Settings</h2><div class=\" sidebar-elems\" ></div>" ;
652
+ let v = layout:: render (
653
+ & shared. layout ,
654
+ & page,
655
+ sidebar,
656
+ |buf : & mut Buffer | {
657
+ write ! (
658
+ buf,
659
+ "<div class=\" main-heading\" >\
660
+ <h1>Rustdoc settings</h1>\
661
+ <span class=\" out-of-band\" >\
662
+ <a id=\" back\" href=\" javascript:void(0)\" onclick=\" history.back();\" >\
663
+ Back\
664
+ </a>\
665
+ </span>\
666
+ </div>\
667
+ <noscript>\
668
+ <section>\
669
+ You need to enable JavaScript be able to update your settings.\
670
+ </section>\
671
+ </noscript>\
672
+ <script defer src=\" {static_root_path}{settings_js}\" ></script>",
673
+ static_root_path = page. get_static_root_path( ) ,
674
+ settings_js = static_files:: STATIC_FILES . settings_js,
675
+ ) ;
676
+ // Pre-load all theme CSS files, so that switching feels seamless.
677
+ //
678
+ // When loading settings.html as a popover, the equivalent HTML is
679
+ // generated in main.js.
680
+ for file in & shared. style_files {
681
+ if let Ok ( theme) = file. basename ( ) {
682
+ write ! (
683
+ buf,
684
+ "<link rel=\" preload\" href=\" {root_path}{theme}{suffix}.css\" \
685
+ as=\" style\" >",
686
+ root_path = page. static_root_path. unwrap_or( "" ) ,
687
+ suffix = page. resource_suffix,
688
+ ) ;
689
+ }
684
690
}
685
- }
686
- } ,
687
- & shared. style_files ,
688
- ) ;
689
- shared. fs . write ( settings_file, v) ?;
691
+ } ,
692
+ & shared. style_files ,
693
+ ) ;
694
+ shared. fs . write ( settings_file, v) ?;
690
695
691
- // Generating help page.
692
- page. title = "Help" ;
693
- page. description = "Documentation for Rustdoc" ;
694
- page. root_path = "./" ;
695
- page. rust_logo = true ;
696
+ // Generating help page.
697
+ page. title = "Help" ;
698
+ page. description = "Documentation for Rustdoc" ;
699
+ page. root_path = "./" ;
700
+ page. rust_logo = true ;
696
701
697
- let sidebar = "<h2 class=\" location\" >Help</h2><div class=\" sidebar-elems\" ></div>" ;
698
- let v = layout:: render (
699
- & shared. layout ,
700
- & page,
701
- sidebar,
702
- |buf : & mut Buffer | {
703
- write ! (
704
- buf,
705
- "<div class=\" main-heading\" >\
706
- <h1>Rustdoc help</h1>\
707
- <span class=\" out-of-band\" >\
708
- <a id=\" back\" href=\" javascript:void(0)\" onclick=\" history.back();\" >\
709
- Back\
710
- </a>\
711
- </span>\
712
- </div>\
713
- <noscript>\
714
- <section>\
715
- <p>You need to enable JavaScript to use keyboard commands or search.</p>\
716
- <p>For more information, browse the <a href=\" https://doc.rust-lang.org/rustdoc/\" >rustdoc handbook</a>.</p>\
717
- </section>\
718
- </noscript>",
719
- )
720
- } ,
721
- & shared. style_files ,
722
- ) ;
723
- shared. fs . write ( help_file, v) ?;
702
+ let sidebar = "<h2 class=\" location\" >Help</h2><div class=\" sidebar-elems\" ></div>" ;
703
+ let v = layout:: render (
704
+ & shared. layout ,
705
+ & page,
706
+ sidebar,
707
+ |buf : & mut Buffer | {
708
+ write ! (
709
+ buf,
710
+ "<div class=\" main-heading\" >\
711
+ <h1>Rustdoc help</h1>\
712
+ <span class=\" out-of-band\" >\
713
+ <a id=\" back\" href=\" javascript:void(0)\" onclick=\" history.back();\" >\
714
+ Back\
715
+ </a>\
716
+ </span>\
717
+ </div>\
718
+ <noscript>\
719
+ <section>\
720
+ <p>You need to enable JavaScript to use keyboard commands or search.</p>\
721
+ <p>For more information, browse the <a href=\" https://doc.rust-lang.org/rustdoc/\" >rustdoc handbook</a>.</p>\
722
+ </section>\
723
+ </noscript>",
724
+ )
725
+ } ,
726
+ & shared. style_files ,
727
+ ) ;
728
+ shared. fs . write ( help_file, v) ?;
729
+ }
724
730
725
- if shared. layout . scrape_examples_extension {
731
+ // if to avoid writing files to doc root unless we're on the final invocation
732
+ if shared. layout . scrape_examples_extension && shared. should_merge . write_rendered_cci {
726
733
page. title = "About scraped examples" ;
727
734
page. description = "How the scraped examples feature works in Rustdoc" ;
728
735
let v = layout:: render (
0 commit comments