From cc3ffe4c912ff00baeec1f52bb16389136a23a27 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 10 Sep 2024 22:03:54 -0700 Subject: Tweak breadcrumbs list --- src/librustdoc/html/static/css/rustdoc.css | 5 +++++ src/librustdoc/html/static/js/main.js | 11 ++++------- src/librustdoc/html/templates/print_item.html | 11 +++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src/librustdoc/html') diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 2dfe5107210..0237677f9d4 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -194,6 +194,11 @@ h1, h2, h3, h4 { display: flex; align-items: end; } +.rustdoc-breadcrumbs a { + padding: 4px 0; + margin: -4px 0; + z-index: 1; +} /* The only headings that get underlines are: Markdown-generated headings within the top-doc Rustdoc-generated h2 section headings (e.g. "Implementations", "Required Methods", etc) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 3e8c903afcb..2fb686effc1 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1,6 +1,6 @@ // Local js definitions: /* global addClass, getSettingValue, hasClass, searchState, updateLocalStorage */ -/* global onEach, onEachLazy, removeClass, getVar */ +/* global onEachLazy, removeClass, getVar */ "use strict"; @@ -1826,14 +1826,11 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm return; } but.onclick = () => { - const parent = but.parentElement; const path = []; - - onEach(parent.childNodes, child => { - if (child.tagName === "A") { - path.push(child.textContent); - } + onEachLazy(document.querySelectorAll(".rustdoc-breadcrumbs a"), a => { + path.push(a.textContent); }); + path.push(document.querySelector("title").textContent.split(" ")[0]); copyContentToClipboard(path.join("::")); copyButtonAnimation(but); diff --git a/src/librustdoc/html/templates/print_item.html b/src/librustdoc/html/templates/print_item.html index 2c9f8dbddf0..32ded1fbe42 100644 --- a/src/librustdoc/html/templates/print_item.html +++ b/src/librustdoc/html/templates/print_item.html @@ -1,8 +1,11 @@
{# #} {% if !path_components.is_empty() %} - {% for component in path_components %} - {{component.name}}:: + {% for (i, component) in path_components.iter().enumerate() %} + {% if i != 0 %} + :: + {% endif %} + {{component.name}} {% endfor %} {% endif %} @@ -15,7 +18,7 @@ Copy item path {# #} {# #} {# #} - + {# #} {% if !stability_since_raw.is_empty() %} {{ stability_since_raw|safe +}} @@ -26,5 +29,5 @@ source {#+ #} {% else %} {% endmatch %} - + {# #}
{# #} -- cgit 1.4.1-3-g733a5