Add an option for the source code link generation
This commit is contained in:
parent
023231a709
commit
2104bf27d4
@ -276,6 +276,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
crate show_type_layout: bool,
|
||||
crate unstable_features: rustc_feature::UnstableFeatures,
|
||||
crate emit: Vec<EmitType>,
|
||||
/// If `true`, HTML source pages will generate links for items to their definition.
|
||||
crate generate_link_to_definition: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
@ -655,6 +657,7 @@ fn println_condition(condition: Condition) {
|
||||
let generate_redirect_map = matches.opt_present("generate-redirect-map");
|
||||
let show_type_layout = matches.opt_present("show-type-layout");
|
||||
let nocapture = matches.opt_present("nocapture");
|
||||
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
|
||||
|
||||
let (lint_opts, describe_lints, lint_cap) =
|
||||
get_cmd_lint_options(matches, error_format, &debugging_opts);
|
||||
@ -721,6 +724,7 @@ fn println_condition(condition: Condition) {
|
||||
crate_name.as_deref(),
|
||||
),
|
||||
emit,
|
||||
generate_link_to_definition,
|
||||
},
|
||||
crate_name,
|
||||
output_format,
|
||||
|
@ -396,6 +396,7 @@ fn init(
|
||||
unstable_features,
|
||||
generate_redirect_map,
|
||||
show_type_layout,
|
||||
generate_link_to_definition,
|
||||
..
|
||||
} = options;
|
||||
|
||||
@ -456,8 +457,13 @@ fn init(
|
||||
}
|
||||
}
|
||||
|
||||
let (mut krate, local_sources, matches) =
|
||||
collect_spans_and_sources(tcx, krate, &src_root, include_sources);
|
||||
let (mut krate, local_sources, matches) = collect_spans_and_sources(
|
||||
tcx,
|
||||
krate,
|
||||
&src_root,
|
||||
include_sources,
|
||||
generate_link_to_definition,
|
||||
);
|
||||
|
||||
let (sender, receiver) = channel();
|
||||
let mut scx = SharedContext {
|
||||
|
@ -20,11 +20,14 @@
|
||||
krate: clean::Crate,
|
||||
src_root: &std::path::Path,
|
||||
include_sources: bool,
|
||||
generate_link_to_definition: bool,
|
||||
) -> (clean::Crate, FxHashMap<std::path::PathBuf, String>, FxHashMap<(u32, u32), LinkFromSrc>) {
|
||||
let mut visitor = SpanMapVisitor { tcx, matches: FxHashMap::default() };
|
||||
|
||||
if include_sources {
|
||||
intravisit::walk_crate(&mut visitor, tcx.hir().krate());
|
||||
if generate_link_to_definition {
|
||||
intravisit::walk_crate(&mut visitor, tcx.hir().krate());
|
||||
}
|
||||
let (krate, sources) = sources::collect_local_sources(tcx, src_root, krate);
|
||||
(krate, sources, visitor.matches)
|
||||
} else {
|
||||
|
@ -607,6 +607,13 @@ fn opts() -> Vec<RustcOptGroup> {
|
||||
unstable("nocapture", |o| {
|
||||
o.optflag("", "nocapture", "Don't capture stdout and stderr of tests")
|
||||
}),
|
||||
unstable("generate-link-to-definition", |o| {
|
||||
o.optflag(
|
||||
"",
|
||||
"generate-link-to-definition",
|
||||
"Make the identifiers in the HTML source code pages navigable",
|
||||
)
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user