Skip to content

Commit 7ab27c5

Browse files
Add unstable --no-html-source rustdoc flag
1 parent f2f999e commit 7ab27c5

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/librustdoc/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ pub(crate) struct RenderOptions {
273273
pub(crate) call_locations: AllCallLocations,
274274
/// If `true`, Context::init will not emit shared files.
275275
pub(crate) no_emit_shared: bool,
276+
/// If `true`, HTML source code pages won't be generated.
277+
pub(crate) html_no_source: bool,
276278
}
277279

278280
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@@ -686,6 +688,7 @@ impl Options {
686688
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
687689
let extern_html_root_takes_precedence =
688690
matches.opt_present("extern-html-root-takes-precedence");
691+
let html_no_source = matches.opt_present("html-no-source");
689692

690693
if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
691694
diag.struct_err(
@@ -769,6 +772,7 @@ impl Options {
769772
generate_link_to_definition,
770773
call_locations,
771774
no_emit_shared: false,
775+
html_no_source,
772776
};
773777
Ok((options, render_options))
774778
}

src/librustdoc/html/render/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
463463
generate_link_to_definition,
464464
call_locations,
465465
no_emit_shared,
466+
html_no_source,
466467
..
467468
} = options;
468469

@@ -488,7 +489,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
488489
scrape_examples_extension: !call_locations.is_empty(),
489490
};
490491
let mut issue_tracker_base_url = None;
491-
let mut include_sources = true;
492+
let mut include_sources = !html_no_source;
492493

493494
// Crawl the crate attributes looking for attributes which control how we're
494495
// going to emit HTML

src/librustdoc/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,9 @@ fn opts() -> Vec<RustcOptGroup> {
656656
"[rust]",
657657
)
658658
}),
659+
unstable("html-no-source", |o| {
660+
o.optflag("", "html-no-source", "Disable HTML source code pages generation")
661+
}),
659662
]
660663
}
661664

0 commit comments

Comments
 (0)