From b72de9be74dd5ac1d8b23d5ece03a7690274a14c Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 16 Sep 2022 13:40:21 -0700 Subject: [PATCH 1/2] 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). --- src/librustdoc/html/render/mod.rs | 35 +++++++++++----------- src/librustdoc/html/render/write_shared.rs | 4 +-- src/librustdoc/html/static/css/rustdoc.css | 9 ++---- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 1e6f20d2b491c..ced0ebdbb864a 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -294,16 +294,15 @@ impl AllTypes { impl AllTypes { fn print(self, f: &mut Buffer) { - fn print_entries(f: &mut Buffer, e: &FxHashSet, title: &str, class: &str) { + fn print_entries(f: &mut Buffer, e: &FxHashSet, title: &str) { if !e.is_empty() { let mut e: Vec<&ItemEntry> = e.iter().collect(); e.sort(); write!( f, - "

{}

    ", + "

    {}

      ", title.replace(' ', "-"), // IDs cannot contain whitespaces. - title, - class + title ); for s in e.iter() { @@ -321,20 +320,20 @@ impl AllTypes { ); // Note: print_entries does not escape the title, because we know the current set of titles // doesn't require escaping. - print_entries(f, &self.structs, "Structs", "structs"); - print_entries(f, &self.enums, "Enums", "enums"); - print_entries(f, &self.unions, "Unions", "unions"); - print_entries(f, &self.primitives, "Primitives", "primitives"); - print_entries(f, &self.traits, "Traits", "traits"); - print_entries(f, &self.macros, "Macros", "macros"); - print_entries(f, &self.attributes, "Attribute Macros", "attributes"); - print_entries(f, &self.derives, "Derive Macros", "derives"); - print_entries(f, &self.functions, "Functions", "functions"); - print_entries(f, &self.typedefs, "Typedefs", "typedefs"); - print_entries(f, &self.trait_aliases, "Trait Aliases", "trait-aliases"); - print_entries(f, &self.opaque_tys, "Opaque Types", "opaque-types"); - print_entries(f, &self.statics, "Statics", "statics"); - print_entries(f, &self.constants, "Constants", "constants") + print_entries(f, &self.structs, "Structs"); + print_entries(f, &self.enums, "Enums"); + print_entries(f, &self.unions, "Unions"); + print_entries(f, &self.primitives, "Primitives"); + print_entries(f, &self.traits, "Traits"); + print_entries(f, &self.macros, "Macros"); + print_entries(f, &self.attributes, "Attribute Macros"); + print_entries(f, &self.derives, "Derive Macros"); + print_entries(f, &self.functions, "Functions"); + print_entries(f, &self.typedefs, "Typedefs"); + print_entries(f, &self.trait_aliases, "Trait Aliases"); + print_entries(f, &self.opaque_tys, "Opaque Types"); + print_entries(f, &self.statics, "Statics"); + print_entries(f, &self.constants, "Constants"); } } diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index fc4d46fe6b6f1..1c88528aa20a9 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -519,12 +519,12 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex}; let content = format!( "

      \ List of all crates\ -

        {}
      ", +
        {}
      ", krates .iter() .map(|s| { format!( - "
    • {}
    • ", + "
    • {}
    • ", ensure_trailing_slash(s), s ) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index ccb302620603c..7570c92c211ed 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -207,7 +207,6 @@ a.source, .out-of-band, span.since, details.rustdoc-toggle > summary::before, -.content ul.crate a.crate, a.srclink, #help-button > button, details.rustdoc-toggle.top-doc > summary, @@ -218,7 +217,7 @@ details.rustdoc-toggle.non-exhaustive > summary::before, .more-examples-toggle summary, .more-examples-toggle .hide-more, .example-links a, /* This selector is for the items listed in the "all items" page. */ -#main-content > ul.docblock > li > a { +ul.all-items { font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif; } @@ -788,6 +787,7 @@ h2.small-section-header > .anchor { content: 'ยง'; } +.all-items a:hover, .docblock a:not(.srclink):not(.test-arrow):not(.scrape-help):hover, .docblock-short a:not(.srclink):not(.test-arrow):not(.scrape-help):hover, .item-info a { text-decoration: underline; @@ -1517,10 +1517,7 @@ kbd { cursor: default; } -#main-content > ul { - padding-left: 10px; -} -#main-content > ul > li { +ul.all-items > li { list-style: none; } From a87a883f4adfc6be528a04216a3615e4907fffd4 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 16 Sep 2022 14:40:24 -0700 Subject: [PATCH 2/2] rustdoc: update test case for All Crates page --- src/test/rustdoc/index-page.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/rustdoc/index-page.rs b/src/test/rustdoc/index-page.rs index be668a1276a01..5677019fbb88e 100644 --- a/src/test/rustdoc/index-page.rs +++ b/src/test/rustdoc/index-page.rs @@ -6,6 +6,6 @@ // @has foo/../index.html // @has - '//span[@class="in-band"]' 'List of all crates' -// @has - '//ul[@class="crate mod"]//a[@href="foo/index.html"]' 'foo' -// @has - '//ul[@class="crate mod"]//a[@href="all_item_types/index.html"]' 'all_item_types' +// @has - '//ul[@class="all-items"]//a[@href="foo/index.html"]' 'foo' +// @has - '//ul[@class="all-items"]//a[@href="all_item_types/index.html"]' 'all_item_types' pub struct Foo;