mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Only list crates on the crate page
This commit is contained in:
parent
e081cd48f4
commit
a2ba9ef1ff
@ -200,8 +200,15 @@ impl<'tcx> Context<'tcx> {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
let keywords = make_item_keywords(it);
|
let keywords = make_item_keywords(it);
|
||||||
|
let name;
|
||||||
|
let tyname_s = if it.is_crate() {
|
||||||
|
name = format!("{} crate", tyname);
|
||||||
|
name.as_str()
|
||||||
|
} else {
|
||||||
|
tyname.as_str()
|
||||||
|
};
|
||||||
let page = layout::Page {
|
let page = layout::Page {
|
||||||
css_class: tyname.as_str(),
|
css_class: tyname_s,
|
||||||
root_path: &self.root_path(),
|
root_path: &self.root_path(),
|
||||||
static_root_path: self.shared.static_root_path.as_deref(),
|
static_root_path: self.shared.static_root_path.as_deref(),
|
||||||
title: &title,
|
title: &title,
|
||||||
|
@ -565,9 +565,12 @@ function hideThemeButtonState() {
|
|||||||
window.initSidebarItems = function(items) {
|
window.initSidebarItems = function(items) {
|
||||||
var sidebar = document.getElementsByClassName("sidebar-elems")[0];
|
var sidebar = document.getElementsByClassName("sidebar-elems")[0];
|
||||||
var current = window.sidebarCurrent;
|
var current = window.sidebarCurrent;
|
||||||
var isModule = hasClass(document.body, "mod");
|
|
||||||
|
|
||||||
function addSidebarCrates(crates) {
|
function addSidebarCrates(crates) {
|
||||||
|
if (!hasClass(document.body, "crate")) {
|
||||||
|
// We only want to list crates on the crate page.
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Draw a convenient sidebar of known crates if we have a listing
|
// Draw a convenient sidebar of known crates if we have a listing
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
div.className = "block crate";
|
div.className = "block crate";
|
||||||
@ -634,6 +637,7 @@ function hideThemeButtonState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sidebar) {
|
if (sidebar) {
|
||||||
|
var isModule = hasClass(document.body, "mod");
|
||||||
if (!isModule) {
|
if (!isModule) {
|
||||||
block("primitive", "Primitive Types");
|
block("primitive", "Primitive Types");
|
||||||
block("mod", "Modules");
|
block("mod", "Modules");
|
||||||
|
@ -17,12 +17,11 @@ click: "#structs + table td > a"
|
|||||||
|
|
||||||
// PAGE: struct.Foo.html
|
// PAGE: struct.Foo.html
|
||||||
assert: (".sidebar .location", 2)
|
assert: (".sidebar .location", 2)
|
||||||
// We check that we have the crates list and that the "current" on is still "test_docs".
|
// We check that there is no crate listed outside of the top level.
|
||||||
assert: (".sidebar-elems > .crate > ul > li > a.current", "test_docs")
|
assert-false: ".sidebar-elems > .crate"
|
||||||
// We now move to the other crate to check if its submodules have the correct sidebar elements too.
|
|
||||||
click: ".sidebar-elems > .crate > ul > li:first-child > a"
|
|
||||||
|
|
||||||
// PAGE: lib2/index.html
|
// PAGE: lib2/index.html
|
||||||
|
goto: file://|DOC_PATH|/lib2/index.html
|
||||||
assert: (".sidebar > .location", "Crate lib2")
|
assert: (".sidebar > .location", "Crate lib2")
|
||||||
// We check that we have the crates list and that the "current" on is now "lib2".
|
// We check that we have the crates list and that the "current" on is now "lib2".
|
||||||
assert: (".sidebar-elems > .crate > ul > li > a.current", "lib2")
|
assert: (".sidebar-elems > .crate > ul > li > a.current", "lib2")
|
||||||
@ -36,12 +35,12 @@ click: "#functions + table td > a"
|
|||||||
// In items containing no items (like functions or constants) and in modules, we have one
|
// In items containing no items (like functions or constants) and in modules, we have one
|
||||||
// "location" elements.
|
// "location" elements.
|
||||||
assert: (".sidebar .location", 1)
|
assert: (".sidebar .location", 1)
|
||||||
// We check that we still have the crates list and that the "current" on is still "lib2".
|
// We check that we don't have the crate list.
|
||||||
assert: (".sidebar-elems > .crate > ul > li > a.current", "lib2")
|
assert-false: ".sidebar-elems > .crate"
|
||||||
goto: ./module/sub_module/sub_sub_module/index.html
|
goto: ./module/sub_module/sub_sub_module/index.html
|
||||||
|
|
||||||
assert: (".sidebar > .location", "Module sub_sub_module")
|
assert: (".sidebar > .location", "Module sub_sub_module")
|
||||||
assert: (".sidebar-elems > .crate > ul > li:nth-child(2) > a", "test_docs")
|
// We check that we don't have the crate list.
|
||||||
assert: (".sidebar-elems > .crate > ul > li:nth-child(2) > a", "href", "../../../../test_docs/index.html")
|
assert-false: ".sidebar-elems > .crate"
|
||||||
assert: (".sidebar-elems > .items > ul > li:nth-child(1)", "Functions")
|
assert: (".sidebar-elems > .items > ul > li:nth-child(1)", "Functions")
|
||||||
assert: ("#functions + table td > a", "foo")
|
assert: ("#functions + table td > a", "foo")
|
||||||
|
Loading…
Reference in New Issue
Block a user