diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs
index dc29add933314..99e96fdcf1eb4 100644
--- a/src/librustdoc/html/layout.rs
+++ b/src/librustdoc/html/layout.rs
@@ -34,6 +34,12 @@ crate struct Page<'a> {
crate static_extra_scripts: &'a [&'a str],
}
+impl<'a> Page<'a> {
+ crate fn get_static_root_path(&self) -> &str {
+ self.static_root_path.unwrap_or(self.root_path)
+ }
+}
+
crate fn render(
layout: &Layout,
page: &Page<'_>,
@@ -41,7 +47,7 @@ crate fn render(
t: T,
style_files: &[StylePath],
) -> String {
- let static_root_path = page.static_root_path.unwrap_or(page.root_path);
+ let static_root_path = page.get_static_root_path();
format!(
"\
\
diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs
index e0c1fd06e7b6c..4e17dc8d3a7d0 100644
--- a/src/librustdoc/html/render/context.rs
+++ b/src/librustdoc/html/render/context.rs
@@ -215,7 +215,7 @@ impl<'tcx> Context<'tcx> {
&self.shared.layout,
&page,
|buf: &mut _| print_sidebar(self, it, buf),
- |buf: &mut _| print_item(self, it, buf),
+ |buf: &mut _| print_item(self, it, buf, &page),
&self.shared.style_files,
)
} else {
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 4b7664f28a149..a08a340e3a999 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -22,9 +22,10 @@ use crate::formats::{AssocItemRender, Impl, RenderMode};
use crate::html::escape::Escape;
use crate::html::format::{print_abi_with_space, print_where_clause, Buffer, PrintWithSpace};
use crate::html::highlight;
+use crate::html::layout::Page;
use crate::html::markdown::MarkdownSummaryLine;
-pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer) {
+pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, page: &Page<'_>) {
debug_assert!(!item.is_stripped());
// Write the breadcrumb trail header for the top
buf.write_str("");
@@ -74,7 +75,16 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer)
}
}
write!(buf, "{}", item.type_(), item.name.as_ref().unwrap());
- write!(buf, "");
+ write!(
+ buf,
+ "",
+ static_root_path = page.get_static_root_path(),
+ suffix = page.resource_suffix,
+ );
buf.write_str(""); // in-band
buf.write_str("");
diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs
index c493801d9907f..d0518cb6862fe 100644
--- a/src/librustdoc/html/render/write_shared.rs
+++ b/src/librustdoc/html/render/write_shared.rs
@@ -207,6 +207,7 @@ pub(super) fn write_shared(
}
write_toolchain("brush.svg", static_files::BRUSH_SVG)?;
write_toolchain("wheel.svg", static_files::WHEEL_SVG)?;
+ write_toolchain("clipboard.svg", static_files::CLIPBOARD_SVG)?;
write_toolchain("down-arrow.svg", static_files::DOWN_ARROW_SVG)?;
let mut themes: Vec<&String> = themes.iter().collect();
diff --git a/src/librustdoc/html/static/clipboard.svg b/src/librustdoc/html/static/clipboard.svg
new file mode 100644
index 0000000000000..8adbd99630488
--- /dev/null
+++ b/src/librustdoc/html/static/clipboard.svg
@@ -0,0 +1 @@
+
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index a03d20c053dfd..dc65e14ab37b8 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -1252,15 +1252,31 @@ function hideThemeButtonState() {
document.execCommand('copy');
document.body.removeChild(el);
- but.textContent = '✓';
+ // There is always one children, but multiple childNodes.
+ but.children[0].style.display = 'none';
+
+ var tmp;
+ if (but.childNodes.length < 2) {
+ tmp = document.createTextNode('✓');
+ but.appendChild(tmp);
+ } else {
+ onEachLazy(but.childNodes, function(e) {
+ if (e.nodeType === Node.TEXT_NODE) {
+ tmp = e;
+ return true;
+ }
+ });
+ tmp.textContent = '✓';
+ }
if (reset_button_timeout !== null) {
window.clearTimeout(reset_button_timeout);
}
function reset_button() {
- but.textContent = '⎘';
+ tmp.textContent = '';
reset_button_timeout = null;
+ but.children[0].style.display = "";
}
reset_button_timeout = window.setTimeout(reset_button, 1000);
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 42a85fcce030a..9e776f83c8d1b 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -1321,11 +1321,12 @@ h4 > .notable-traits {
}
#copy-path {
- height: 30px;
- font-size: 18px;
margin-left: 10px;
- padding: 0 6px;
- width: 28px;
+ padding: 0;
+ padding-left: 2px;
+}
+#copy-path> img {
+ margin-bottom: 2px;
}
#theme-choices {
diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css
index aace0b3c037ca..63d42264f76cf 100644
--- a/src/librustdoc/html/static/themes/ayu.css
+++ b/src/librustdoc/html/static/themes/ayu.css
@@ -509,7 +509,7 @@ kbd {
color: #fff;
}
-#theme-picker > img, #settings-menu > img {
+#theme-picker > img, #settings-menu > img, #copy-path > img {
filter: invert(100);
}
diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs
index 2b73bd5d52ee6..1abb1f7294a18 100644
--- a/src/librustdoc/html/static_files.rs
+++ b/src/librustdoc/html/static_files.rs
@@ -41,6 +41,9 @@ crate static BRUSH_SVG: &[u8] = include_bytes!("static/brush.svg");
/// The file contents of `wheel.svg`, the icon used for the settings button.
crate static WHEEL_SVG: &[u8] = include_bytes!("static/wheel.svg");
+/// The file contents of `clipboard.svg`, the icon used for the "copy path" button.
+crate static CLIPBOARD_SVG: &[u8] = include_bytes!("static/clipboard.svg");
+
/// The file contents of `down-arrow.svg`, the icon used for the crate choice combobox.
crate static DOWN_ARROW_SVG: &[u8] = include_bytes!("static/down-arrow.svg");