1
Fork 0

rustdoc: change .src-line-numbers > span to .src-line-numbers > a

This allows people to treat them like real links, such as right-click to
copy URL, and makes the line numbers in a scraped example work at all,
when before this commit was added, they had the clickable pointer cursor
but did not actually do anything when clicked.
This commit is contained in:
Michael Howell 2022-10-27 11:16:30 -07:00
parent 2afca78a0b
commit 07bb2f701e
6 changed files with 72 additions and 47 deletions

View file

@ -2888,9 +2888,6 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite
})()
.unwrap_or(rustc_span::DUMMY_SP);
// The root path is the inverse of Context::current
let root_path = vec!["../"; cx.current.len() - 1].join("");
let mut decoration_info = FxHashMap::default();
decoration_info.insert("highlight focus", vec![byte_ranges.remove(0)]);
decoration_info.insert("highlight", byte_ranges);
@ -2900,9 +2897,13 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite
contents_subset,
file_span,
cx,
&root_path,
&cx.root_path(),
highlight::DecorationInfo(decoration_info),
sources::SourceContext::Embedded { offset: line_min, needs_expansion },
sources::SourceContext::Embedded {
url: &call_data.url,
offset: line_min,
needs_expansion,
},
);
write!(w, "</div></div>");