rustdoc: clean up the In [name] up-pointer
This commit makes three changes for consistency and readability: - It shows the sibling navigation on module pages. It's weird that it didn't work before, and is inconsistent with everything else (even Crates have sibling navigation with other Crates). - It hides the "In [parent]" header if it's the same as the current crate, and if there's no other header between them. We need to keep it on modules and types, since they have their own header and data between them, and we don't want to show siblings under a header implying that they're children. - It adds a margin to deal with the headers butting directly into the branding lockup.
This commit is contained in:
parent
b0d76a7efe
commit
47c46324aa
9 changed files with 50 additions and 16 deletions
|
@ -457,22 +457,27 @@ function preLoadCss(cssUrl) {
|
|||
return;
|
||||
}
|
||||
|
||||
const modpath = hasClass(document.body, "mod") ? "../" : "";
|
||||
|
||||
const h3 = document.createElement("h3");
|
||||
h3.innerHTML = `<a href="index.html#${id}">${longty}</a>`;
|
||||
h3.innerHTML = `<a href="${modpath}index.html#${id}">${longty}</a>`;
|
||||
const ul = document.createElement("ul");
|
||||
ul.className = "block " + shortty;
|
||||
|
||||
for (const name of filtered) {
|
||||
let path;
|
||||
if (shortty === "mod") {
|
||||
path = name + "/index.html";
|
||||
path = `${modpath}${name}/index.html`;
|
||||
} else {
|
||||
path = shortty + "." + name + ".html";
|
||||
path = `${modpath}${shortty}.${name}.html`;
|
||||
}
|
||||
let current_page = document.location.href.toString();
|
||||
if (current_page.endsWith("/")) {
|
||||
current_page += "index.html";
|
||||
}
|
||||
const current_page = document.location.href.split("/").pop();
|
||||
const link = document.createElement("a");
|
||||
link.href = path;
|
||||
if (path === current_page) {
|
||||
if (link.href === current_page) {
|
||||
link.className = "current";
|
||||
}
|
||||
link.textContent = name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue