Add unstable `--no-html-source` rustdoc flag
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 81fb13f..1ce7efd 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -273,6 +273,8 @@
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 @@
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 @@
generate_link_to_definition,
call_locations,
no_emit_shared: false,
+ html_no_source,
};
Ok((options, render_options))
}
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index d7ff248..bb1c186 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -463,6 +463,7 @@
generate_link_to_definition,
call_locations,
no_emit_shared,
+ html_no_source,
..
} = options;
@@ -488,7 +489,7 @@
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
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 8220df5..92e06f3 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -656,6 +656,9 @@
"[rust]",
)
}),
+ unstable("html-no-source", |o| {
+ o.optflag("", "html-no-source", "Disable HTML source code pages generation")
+ }),
]
}