Skip to content

Commit 9b637fa

Browse files
Improve display of the separation between page items and siblings in the sidebar
1 parent a2ba9ef commit 9b637fa

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/librustdoc/html/render/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17381738
// to navigate the documentation (though slightly inefficiently).
17391739

17401740
if !it.is_mod() {
1741-
buffer.write_str("<p class=\"location\">");
1741+
buffer.write_str("<p class=\"location\">Other items in<br>");
17421742
for (i, name) in cx.current.iter().take(parentlen).enumerate() {
17431743
if i > 0 {
17441744
buffer.write_str("::<wbr>");

src/librustdoc/html/static/rustdoc.css

+4-1
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,12 @@ nav.sub {
304304
border: none;
305305
}
306306

307-
.location a:first-child {
307+
.location a:first-of-type {
308308
font-weight: 500;
309309
}
310+
.location a:hover {
311+
text-decoration: underline;
312+
}
310313

311314
.block {
312315
padding: 0;

src/test/rustdoc-gui/sidebar.goml

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ click: "#structs + table td > a"
1919
assert: (".sidebar .location", 2)
2020
// We check that there is no crate listed outside of the top level.
2121
assert-false: ".sidebar-elems > .crate"
22+
// We now go back to the crate page to click on the "lib2" crate link.
23+
goto: file://|DOC_PATH|/test_docs/index.html
24+
click: ".sidebar-elems > .crate > ul > li:first-child > a"
2225

2326
// PAGE: lib2/index.html
2427
goto: file://|DOC_PATH|/lib2/index.html
@@ -35,10 +38,17 @@ click: "#functions + table td > a"
3538
// In items containing no items (like functions or constants) and in modules, we have one
3639
// "location" elements.
3740
assert: (".sidebar .location", 1)
41+
// There is a "<br>" tag between "in" and "lib2", but it doesn't count as a space.
42+
assert: (".sidebar .sidebar-elems .location", "Other items inlib2")
43+
// We check that we don't have the crate list.
44+
assert-false: ".sidebar-elems > .crate"
45+
46+
goto: ./module/index.html
47+
assert: (".sidebar > .location", "Module module")
3848
// We check that we don't have the crate list.
3949
assert-false: ".sidebar-elems > .crate"
40-
goto: ./module/sub_module/sub_sub_module/index.html
4150

51+
goto: ./sub_module/sub_sub_module/index.html
4252
assert: (".sidebar > .location", "Module sub_sub_module")
4353
// We check that we don't have the crate list.
4454
assert-false: ".sidebar-elems > .crate"

0 commit comments

Comments
 (0)