Skip to content

Commit 9702c6c

Browse files
authored
Rollup merge of #101918 - notriddle:notriddle/all, r=GuillaumeGomez
rustdoc: clean up CSS for All Items and All Crates lists This reduces the amount of CSS, and makes these two pages more consistent (which, necessarily, means changing them a bit). # Before ![image](https://user-images.githubusercontent.com/1593513/190735035-c66b2664-3783-483c-9bc6-89f80e4a5490.png) ![image](https://user-images.githubusercontent.com/1593513/190735134-1d5df81d-58c5-4c86-b066-6dd3031ffc2e.png) # After ![image](https://user-images.githubusercontent.com/1593513/190735261-fc3878bb-0cab-4c4e-a6da-b5f7abd06588.png) ![image](https://user-images.githubusercontent.com/1593513/190735389-935a7836-f2c0-4349-a7d0-7fe5378f6b9a.png)
2 parents 179fd13 + a87a883 commit 9702c6c

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

src/librustdoc/html/render/mod.rs

+17-18
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,15 @@ impl AllTypes {
294294

295295
impl AllTypes {
296296
fn print(self, f: &mut Buffer) {
297-
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, title: &str, class: &str) {
297+
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, title: &str) {
298298
if !e.is_empty() {
299299
let mut e: Vec<&ItemEntry> = e.iter().collect();
300300
e.sort();
301301
write!(
302302
f,
303-
"<h3 id=\"{}\">{}</h3><ul class=\"{} docblock\">",
303+
"<h3 id=\"{}\">{}</h3><ul class=\"all-items\">",
304304
title.replace(' ', "-"), // IDs cannot contain whitespaces.
305-
title,
306-
class
305+
title
307306
);
308307

309308
for s in e.iter() {
@@ -321,20 +320,20 @@ impl AllTypes {
321320
);
322321
// Note: print_entries does not escape the title, because we know the current set of titles
323322
// doesn't require escaping.
324-
print_entries(f, &self.structs, "Structs", "structs");
325-
print_entries(f, &self.enums, "Enums", "enums");
326-
print_entries(f, &self.unions, "Unions", "unions");
327-
print_entries(f, &self.primitives, "Primitives", "primitives");
328-
print_entries(f, &self.traits, "Traits", "traits");
329-
print_entries(f, &self.macros, "Macros", "macros");
330-
print_entries(f, &self.attributes, "Attribute Macros", "attributes");
331-
print_entries(f, &self.derives, "Derive Macros", "derives");
332-
print_entries(f, &self.functions, "Functions", "functions");
333-
print_entries(f, &self.typedefs, "Typedefs", "typedefs");
334-
print_entries(f, &self.trait_aliases, "Trait Aliases", "trait-aliases");
335-
print_entries(f, &self.opaque_tys, "Opaque Types", "opaque-types");
336-
print_entries(f, &self.statics, "Statics", "statics");
337-
print_entries(f, &self.constants, "Constants", "constants")
323+
print_entries(f, &self.structs, "Structs");
324+
print_entries(f, &self.enums, "Enums");
325+
print_entries(f, &self.unions, "Unions");
326+
print_entries(f, &self.primitives, "Primitives");
327+
print_entries(f, &self.traits, "Traits");
328+
print_entries(f, &self.macros, "Macros");
329+
print_entries(f, &self.attributes, "Attribute Macros");
330+
print_entries(f, &self.derives, "Derive Macros");
331+
print_entries(f, &self.functions, "Functions");
332+
print_entries(f, &self.typedefs, "Typedefs");
333+
print_entries(f, &self.trait_aliases, "Trait Aliases");
334+
print_entries(f, &self.opaque_tys, "Opaque Types");
335+
print_entries(f, &self.statics, "Statics");
336+
print_entries(f, &self.constants, "Constants");
338337
}
339338
}
340339

src/librustdoc/html/render/write_shared.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,12 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
519519
let content = format!(
520520
"<h1 class=\"fqn\">\
521521
<span class=\"in-band\">List of all crates</span>\
522-
</h1><ul class=\"crate mod\">{}</ul>",
522+
</h1><ul class=\"all-items\">{}</ul>",
523523
krates
524524
.iter()
525525
.map(|s| {
526526
format!(
527-
"<li><a class=\"crate mod\" href=\"{}index.html\">{}</a></li>",
527+
"<li><a href=\"{}index.html\">{}</a></li>",
528528
ensure_trailing_slash(s),
529529
s
530530
)

src/librustdoc/html/static/css/rustdoc.css

+3-6
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ a.source,
207207
.out-of-band,
208208
span.since,
209209
details.rustdoc-toggle > summary::before,
210-
.content ul.crate a.crate,
211210
a.srclink,
212211
#help-button > button,
213212
details.rustdoc-toggle.top-doc > summary,
@@ -218,7 +217,7 @@ details.rustdoc-toggle.non-exhaustive > summary::before,
218217
.more-examples-toggle summary, .more-examples-toggle .hide-more,
219218
.example-links a,
220219
/* This selector is for the items listed in the "all items" page. */
221-
#main-content > ul.docblock > li > a {
220+
ul.all-items {
222221
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
223222
}
224223

@@ -786,6 +785,7 @@ h2.small-section-header > .anchor {
786785
content: '§';
787786
}
788787

788+
.all-items a:hover,
789789
.docblock a:not(.srclink):not(.test-arrow):not(.scrape-help):hover,
790790
.docblock-short a:not(.srclink):not(.test-arrow):not(.scrape-help):hover, .item-info a {
791791
text-decoration: underline;
@@ -1515,10 +1515,7 @@ kbd {
15151515
cursor: default;
15161516
}
15171517

1518-
#main-content > ul {
1519-
padding-left: 10px;
1520-
}
1521-
#main-content > ul > li {
1518+
ul.all-items > li {
15221519
list-style: none;
15231520
}
15241521

src/test/rustdoc/index-page.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
// @has foo/../index.html
88
// @has - '//span[@class="in-band"]' 'List of all crates'
9-
// @has - '//ul[@class="crate mod"]//a[@href="foo/index.html"]' 'foo'
10-
// @has - '//ul[@class="crate mod"]//a[@href="all_item_types/index.html"]' 'all_item_types'
9+
// @has - '//ul[@class="all-items"]//a[@href="foo/index.html"]' 'foo'
10+
// @has - '//ul[@class="all-items"]//a[@href="all_item_types/index.html"]' 'all_item_types'
1111
pub struct Foo;

0 commit comments

Comments
 (0)