Add unstable --no-html-source rustdoc flag

This commit is contained in:
Guillaume Gomez 2023-08-23 15:53:48 +02:00
parent f2f999e7b2
commit 7ab27c5ed5
3 changed files with 9 additions and 1 deletions

View File

@ -273,6 +273,8 @@ pub(crate) struct RenderOptions {
pub(crate) call_locations: AllCallLocations,
/// If `true`, Context::init will not emit shared files.
pub(crate) no_emit_shared: bool,
/// If `true`, HTML source code pages won't be generated.
pub(crate) html_no_source: bool,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -686,6 +688,7 @@ impl Options {
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
let extern_html_root_takes_precedence =
matches.opt_present("extern-html-root-takes-precedence");
let html_no_source = matches.opt_present("html-no-source");
if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
diag.struct_err(
@ -769,6 +772,7 @@ impl Options {
generate_link_to_definition,
call_locations,
no_emit_shared: false,
html_no_source,
};
Ok((options, render_options))
}

View File

@ -463,6 +463,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
generate_link_to_definition,
call_locations,
no_emit_shared,
html_no_source,
..
} = options;
@ -488,7 +489,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
scrape_examples_extension: !call_locations.is_empty(),
};
let mut issue_tracker_base_url = None;
let mut include_sources = true;
let mut include_sources = !html_no_source;
// Crawl the crate attributes looking for attributes which control how we're
// going to emit HTML

View File

@ -656,6 +656,9 @@ fn opts() -> Vec<RustcOptGroup> {
"[rust]",
)
}),
unstable("html-no-source", |o| {
o.optflag("", "html-no-source", "Disable HTML source code pages generation")
}),
]
}