Skip to content

Commit ecd71c4

Browse files
authored
Unrolled build for rust-lang#131023
Rollup merge of rust-lang#131023 - clubby789:doc-item-path, r=notriddle Copy correct path to clipboard for modules/keywords/primitives Fixes rust-lang#131021
2 parents 63a0bdd + 5726000 commit ecd71c4

File tree

1 file changed

+9
-5
lines changed
  • src/librustdoc/html/static/js

1 file changed

+9
-5
lines changed

Diff for: src/librustdoc/html/static/js/main.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -1828,11 +1828,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
18281828
return;
18291829
}
18301830
but.onclick = () => {
1831-
const path = [];
1832-
onEachLazy(document.querySelectorAll(".rustdoc-breadcrumbs a"), a => {
1833-
path.push(a.textContent);
1834-
});
1835-
path.push(document.querySelector("title").textContent.split(" ")[0]);
1831+
// Most page titles are '<Item> in <path::to::module> - Rust', except
1832+
// modules (which don't have the first part) and keywords/primitives
1833+
// (which don't have a module path)
1834+
const title = document.querySelector("title").textContent.replace(" - Rust", "");
1835+
const [item, module] = title.split(" in ");
1836+
const path = [item];
1837+
if (module !== undefined) {
1838+
path.unshift(module);
1839+
}
18361840

18371841
copyContentToClipboard(path.join("::"));
18381842
copyButtonAnimation(but);

0 commit comments

Comments
 (0)