Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add --no-source option flag to rustdoc
  • Loading branch information
GuillaumeGomez committed Apr 3, 2021
commit adc02e40160961154b799710dce0da0558e341f1
4 changes: 4 additions & 0 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ crate struct RenderOptions {
crate generate_redirect_map: bool,
crate unstable_features: rustc_feature::UnstableFeatures,
crate emit: Vec<EmitType>,
/// Whether the source code should be rendered as HTML.
pub no_source: bool,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -622,6 +624,7 @@ impl Options {
let document_hidden = matches.opt_present("document-hidden-items");
let run_check = matches.opt_present("check");
let generate_redirect_map = matches.opt_present("generate-redirect-map");
let no_source = matches.opt_present("no-source");

let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);

Expand Down Expand Up @@ -684,6 +687,7 @@ impl Options {
crate_name.as_deref(),
),
emit,
no_source,
},
crate_name,
output_format,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
generate_search_filter,
};
let mut issue_tracker_base_url = None;
let mut include_sources = true;
let mut include_sources = !options.no_source;

// Crawl the crate attributes looking for attributes which control how we're
// going to emit HTML
Expand Down
6 changes: 6 additions & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ fn opts() -> Vec<RustcOptGroup> {
"emit",
"Comma separated list of types of output for rustdoc to emit",
"[unversioned-shared-resources,toolchain-shared-resources,invocation-specific]",
stable("no-source", |o| {
o.optflag(
"",
"no-source",
"Prevent source code generation in HTML output format generation. \
This is the same as using the `#![doc(html_no_source)]` attribute.",
)
}),
]
Expand Down