diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 688860f94e183..de237bbd5ad57 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -48,22 +48,10 @@ crate fn render_with_highlighting( decoration_info: Option, ) { debug!("highlighting: ================\n{}\n==============", src); - if let Some((edition_info, class)) = tooltip { - write!( - out, - "
β“˜
", - class, - if let Some(edition_info) = edition_info { - format!(" data-edition=\"{}\"", edition_info) - } else { - String::new() - }, - ); - } write_header(out, class, extra_content); write_code(out, src, edition, context_info, decoration_info); - write_footer(out, playground_button); + write_footer(out, tooltip, playground_button); } fn write_header(out: &mut Buffer, class: Option<&str>, extra_content: Option) { @@ -114,8 +102,25 @@ fn write_code( }); } -fn write_footer(out: &mut Buffer, playground_button: Option<&str>) { - writeln!(out, "{}", playground_button.unwrap_or_default()); +fn write_footer( + out: &mut Buffer, + tooltip: Option<(Option, &str)>, + playground_button: Option<&str>, +) { + writeln!(out, ""); + if let Some((edition_info, class)) = tooltip { + write!( + out, + "
β“˜
", + class, + if let Some(edition_info) = edition_info { + format!(" data-edition=\"{}\"", edition_info) + } else { + String::new() + }, + ); + } + writeln!(out, "{}", playground_button.unwrap_or_default()); } /// How a span of text is classified. Mostly corresponds to token kinds. diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 166e084012724..13c7c0eca3534 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -361,7 +361,7 @@ enum Setting { } impl Setting { - fn display(&self, root_path: &str, suffix: &str) -> String { + fn display(&self) -> String { match *self { Setting::Section { description, ref sub_settings } => format!( "
\ @@ -369,7 +369,7 @@ impl Setting {
{}
", description, - sub_settings.iter().map(|s| s.display(root_path, suffix)).collect::() + sub_settings.iter().map(|s| s.display()).collect::() ), Setting::Toggle { js_data_name, description, default_value } => format!( "
\ @@ -388,7 +388,7 @@ impl Setting {
{}
\ \
", description, @@ -401,8 +401,6 @@ impl Setting { name = opt, )) .collect::(), - root_path, - suffix, ), } } @@ -462,7 +460,7 @@ fn settings(root_path: &str, suffix: &str, theme_names: Vec) -> Result{}\ \ ", - settings.iter().map(|s| s.display(root_path, suffix)).collect::(), + settings.iter().map(|s| s.display()).collect::(), root_path = root_path, suffix = suffix )) @@ -667,8 +665,7 @@ fn short_item_info( message.push_str(&format!(": {}", html.into_string())); } extra_info.push(format!( - "
πŸ‘Ž {}
", - message, + "
πŸ‘Ž {message}
" )); } @@ -680,9 +677,6 @@ fn short_item_info( .filter(|stab| stab.feature != sym::rustc_private) .map(|stab| (stab.level, stab.feature)) { - let mut message = - "πŸ”¬ This is a nightly-only experimental API.".to_owned(); - let mut feature = format!("{}", Escape(&feature.as_str())); if let (Some(url), Some(issue)) = (&cx.shared.issue_tracker_base_url, issue) { feature.push_str(&format!( @@ -692,9 +686,9 @@ fn short_item_info( )); } - message.push_str(&format!(" ({})", feature)); - - extra_info.push(format!("
{}
", message)); + extra_info.push(format!( + "
πŸ”¬ This is a nightly-only experimental API. ({feature})
" + )); } if let Some(portability) = portability(item, parent) { @@ -1292,7 +1286,7 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String { if !out.is_empty() { out.insert_str( 0, - "β“˜\ + "β“˜\
", ); out.push_str("
"); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 9943e23b9281c..6d50f033230b3 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -380,7 +380,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl clean::FunctionItem(ref func) | clean::ForeignFunctionItem(ref func) if func.header.unsafety == hir::Unsafety::Unsafe => { - "⚠" + "⚠" } _ => "", }; diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 0d5ba8e80d242..e29c9939a18e4 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -200,12 +200,12 @@ pub(super) fn write_shared( write_minify( "rustdoc.css", static_files::RUSTDOC_CSS + .replace("/* AUTOREPLACE: */url('icons.woff2')", &ver_url(cx, "icons.woff2")) + .replace("/* AUTOREPLACE: */url('icons.woff')", &ver_url(cx, "icons.woff")) .replace( - "/* AUTOREPLACE: */url(\"toggle-minus.svg\")", - &ver_url(cx, "toggle-minus.svg"), - ) - .replace("/* AUTOREPLACE: */url(\"toggle-plus.svg\")", &ver_url(cx, "toggle-plus.svg")) - .replace("/* AUTOREPLACE: */url(\"down-arrow.svg\")", &ver_url(cx, "down-arrow.svg")), + "AUTOREPLACE: icons-FontAwesome-LICENSE.txt", + &ver_url(cx, "icons-FontAwesome-LICENSE.txt"), + ), cx, options, )?; @@ -247,12 +247,10 @@ pub(super) fn write_shared( write_toolchain("favicon-16x16.png", static_files::RUST_FAVICON_PNG_16)?; write_toolchain("favicon-32x32.png", static_files::RUST_FAVICON_PNG_32)?; } - write_toolchain("brush.svg", static_files::BRUSH_SVG)?; - write_toolchain("wheel.svg", static_files::WHEEL_SVG)?; - write_toolchain("clipboard.svg", static_files::CLIPBOARD_SVG)?; - write_toolchain("down-arrow.svg", static_files::DOWN_ARROW_SVG)?; - write_toolchain("toggle-minus.svg", static_files::TOGGLE_MINUS_PNG)?; - write_toolchain("toggle-plus.svg", static_files::TOGGLE_PLUS_PNG)?; + + write_toolchain("icons.woff", static_files::icons::WOFF)?; + write_toolchain("icons.woff2", static_files::icons::WOFF2)?; + write_toolchain("icons-FontAwesome-LICENSE.txt", static_files::icons::LICENSE)?; let mut themes: Vec<&String> = themes.iter().collect(); themes.sort(); diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 5751ec2cc02b3..4ed496b5db37f 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -84,6 +84,17 @@ unicode-range: U+AC00-D7AF, U+1100-11FF, U+3130-318F, U+A960-A97F, U+D7B0-D7FF; } +/* Icon font generated from hand-picked SVGs */ +/* See AUTOREPLACE: icons-FontAwesome-LICENSE.txt for the Font awesome license. */ +@font-face { + font-family: 'icons'; + src: /* AUTOREPLACE: */url('icons.woff2') format('woff2'), + /* AUTOREPLACE: */url('icons.woff') format('woff'); + font-weight: normal; + font-style: normal; + font-display: swap; +} + * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; @@ -117,6 +128,10 @@ body { font-feature-settings: "kern", "liga"; } +.icon { + font-family: 'icons'; +} + h1 { font-size: 1.5em; } @@ -197,7 +212,6 @@ h1, h2, h3, h4, h5, h6, .item-left > a, div.item-list .out-of-band, span.since, #source-sidebar, #sidebar-toggle, -details.rustdoc-toggle > summary::before, div.impl-items > div:not(.docblock):not(.item-info), .content ul.crate a.crate, a.srclink, /* This selector is for the items listed in the "all items" page. */ @@ -510,6 +524,12 @@ nav.sub { margin-bottom: 10px; } +.rustdoc .docblock > .example-wrap { + /* Override `.docblock > *` style since internal `pre` has `overflow-x: auto` anyways. + Allows us to put `.information` within `.example-wrap` for pure CSS hover. */ + overflow-x: visible; +} + .example-wrap { position: relative; width: 100%; @@ -864,14 +884,17 @@ h2.small-section-header > .anchor { width: calc(100% - 63px); } #crate-search { - min-width: 115px; + flex: none; margin-top: 5px; + display: flex; + border-radius: 4px 0 0 4px; +} +#crate-search > select { + min-width: 115px; padding: 6px; padding-right: 19px; - flex: none; border: 0; border-right: 0; - border-radius: 4px 0 0 4px; outline: none; cursor: pointer; border-right: 1px solid; @@ -880,11 +903,14 @@ h2.small-section-header > .anchor { /* Removes default arrow from firefox */ text-indent: 0.01px; text-overflow: ""; - background-repeat: no-repeat; background-color: transparent; - background-size: 20px; - background-position: calc(100% - 1px) 56%; - background-image: /* AUTOREPLACE: */url("down-arrow.svg"); +} +#crate-search > .icon { + font-size: 20px; + margin: 5px; + margin-left: -19px; + padding-top: 3px; + pointer-events: none; } .search-container > .top-button { position: absolute; @@ -1038,19 +1064,10 @@ body.blur > :not(#help) { display: inline; } -.stab .emoji { +.stab .icon { font-size: 1.2em; } -/* Black one-pixel outline around emoji shapes */ -.emoji { - text-shadow: - 1px 0 0 black, - -1px 0 0 black, - 0 1px 0 black, - 0 -1px 0 black; -} - .module-item .stab, .import-item .stab { border-radius: 3px; @@ -1212,7 +1229,7 @@ h3.variant { .information { position: absolute; left: -25px; - margin-top: 7px; + top: 7px; z-index: 1; } @@ -1427,19 +1444,19 @@ pre.rust { #theme-picker, #settings-menu, #help-button, #copy-path { padding: 4px; + padding-top: 2px; width: 27px; height: 29px; border: 1px solid; border-radius: 3px; cursor: pointer; + text-align: center; + font-size: 17px; } #help-button { right: 30px; font-family: "Fira Sans", Arial, sans-serif; - text-align: center; - font-size: 17px; - padding-top: 2px; } #copy-path { @@ -1588,18 +1605,6 @@ details.rustdoc-toggle > summary.hideme > span { margin-left: 9px; } -details.rustdoc-toggle > summary::before { - content: ""; - cursor: pointer; - width: 17px; - height: max(17px, 1.1em); - background-repeat: no-repeat; - background-position: top left; - display: inline-block; - vertical-align: middle; - opacity: .5; -} - /* Screen readers see the text version at the end the line. Visual readers see the icon at the start of the line, but small and transparent. */ details.rustdoc-toggle > summary::after { @@ -1615,15 +1620,8 @@ details.rustdoc-toggle > summary.hideme::after { content: ""; } -details.rustdoc-toggle > summary:focus::before, -details.rustdoc-toggle > summary:hover::before { - opacity: 1; -} - details.rustdoc-toggle.top-doc > summary, -details.rustdoc-toggle.top-doc > summary::before, -details.rustdoc-toggle.non-exhaustive > summary, -details.rustdoc-toggle.non-exhaustive > summary::before { +details.rustdoc-toggle.non-exhaustive > summary { font-family: 'Fira Sans'; font-size: 16px; } @@ -1664,24 +1662,17 @@ details.rustdoc-toggle[open] > summary.hideme > span { display: none; } -details.undocumented[open] > summary::before, -details.rustdoc-toggle[open] > summary::before, -details.rustdoc-toggle[open] > summary.hideme::before { - background-image: /* AUTOREPLACE: */url("toggle-minus.svg"); -} - -details.undocumented > summary::before, details.rustdoc-toggle > summary::before { - background-image: /* AUTOREPLACE: */url("toggle-plus.svg"); +details.undocumented > summary::before, +details.rustdoc-toggle > summary::before { + font-family: 'icons'; + font-size: 13px; + cursor: pointer; + content: "⊞"; } -details.rustdoc-toggle[open] > summary::before, -details.rustdoc-toggle[open] > summary.hideme::before { - width: 17px; - height: max(17px, 1.1em); - background-repeat: no-repeat; - background-position: top left; - display: inline-block; - content: ""; +details.undocumented[open] > summary::before, +details.rustdoc-toggle[open] > summary::before { + content: "⊟"; } details.rustdoc-toggle[open] > summary::after, @@ -1696,7 +1687,7 @@ details.rustdoc-toggle[open] > summary.hideme::after { to prevent an overlay between the "collapse toggle" and the information tooltip. However, it's not needed with smaller screen width because the doc/code block is always put "one line" below. */ - .docblock > .information:first-child > .tooltip { + .docblock > .example-wrap:first-child > .information { margin-top: 16px; } @@ -2035,6 +2026,7 @@ details.rustdoc-toggle[open] > summary.hideme::after { #theme-picker, #settings-menu { padding: 5px; + padding-top: 3px; width: 31px; height: 31px; } diff --git a/src/librustdoc/html/static/css/settings.css b/src/librustdoc/html/static/css/settings.css index fb8990b30e2ed..0c14bacd04fad 100644 --- a/src/librustdoc/html/static/css/settings.css +++ b/src/librustdoc/html/static/css/settings.css @@ -47,15 +47,17 @@ width: 100%; } -.select-wrapper img { +.select-wrapper .icon { pointer-events: none; position: absolute; right: 0; - bottom: 0; + top: 0; background: #ccc; height: 100%; - width: 28px; - padding: 0px 4px; + padding: 2px 4px; + color: #000; + font-size: 26px; + line-height: 1; } .select-wrapper select option { diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index dea6d08396f31..95680521d17ad 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -239,9 +239,11 @@ details.undocumented > summary::before { color: #999; } -details.rustdoc-toggle > summary::before, -details.undocumented > summary::before { - filter: invert(100%); +details.rustdoc-toggle > summary:focus::before, +details.rustdoc-toggle > summary:hover::before, +details.undocumented > summary:focus::before, +details.undocumented > summary:hover::before { + color: #fff; } #crate-search { @@ -356,48 +358,42 @@ a.test-arrow:hover { pre.compile_fail { border-left: 2px solid rgba(255,0,0,.4); } +.tooltip.compile_fail { + color: rgba(255,0,0,.4); +} -pre.compile_fail:hover, .information:hover + pre.compile_fail { +.example-wrap:hover pre.compile_fail { border-left: 2px solid #f00; } +.example-wrap:hover .tooltip.compile_fail { + color: #f00; +} pre.should_panic { border-left: 2px solid rgba(255,0,0,.4); } - -pre.should_panic:hover, .information:hover + pre.should_panic { - border-left: 2px solid #f00; -} - -pre.ignore { - border-left: 2px solid rgba(255,142,0,.6); -} - -pre.ignore:hover, .information:hover + pre.ignore { - border-left: 2px solid #ff9200; +.tooltip.should_panic { + color: rgba(255,0,0,.4); } -.tooltip.compile_fail { - color: rgba(255,0,0,.5); +.example-wrap:hover pre.should_panic { + border-left: 2px solid #f00; } - -.information > .compile_fail:hover { +.example-wrap:hover .tooltip.should_panic { color: #f00; } -.tooltip.should_panic { - color: rgba(255,0,0,.5); -} - -.information > .should_panic:hover { - color: #f00; +pre.ignore { + border-left: 2px solid rgba(255,142,0,.6); } - .tooltip.ignore { color: rgba(255,142,0,.6); } -.information > .ignore:hover { +.example-wrap:hover pre.ignore { + border-left: 2px solid #ff9200; +} +.example-wrap:hover .tooltip.ignore { color: #ff9200; } @@ -541,13 +537,10 @@ kbd { } #copy-path { - color: #fff; + color: #b2b2b2; } -#copy-path > img { - filter: invert(70%); -} -#copy-path:hover > img { - filter: invert(100%); +#copy-path:hover { + color: #fff; } #theme-picker:hover, #theme-picker:focus, @@ -633,5 +626,5 @@ input:checked + .slider { background: #616161; } .toggle-line:hover .toggle-line-inner { - background: ##898989; + background: #898989; } diff --git a/src/librustdoc/html/static/css/themes/dark.css b/src/librustdoc/html/static/css/themes/dark.css index 6e2cbbecbf712..1c59cde40f60f 100644 --- a/src/librustdoc/html/static/css/themes/dark.css +++ b/src/librustdoc/html/static/css/themes/dark.css @@ -204,9 +204,11 @@ details.undocumented > summary::before { color: #999; } -details.rustdoc-toggle > summary::before, -details.undocumented > summary::before { - filter: invert(100%); +details.rustdoc-toggle > summary:focus::before, +details.rustdoc-toggle > summary:hover::before, +details.undocumented > summary:focus::before, +details.undocumented > summary:hover::before { + color: #fff; } #crate-search { @@ -304,48 +306,42 @@ a.test-arrow:hover{ pre.compile_fail { border-left: 2px solid rgba(255,0,0,.8); } - -pre.compile_fail:hover, .information:hover + pre.compile_fail { - border-left: 2px solid #f00; -} - -pre.should_panic { - border-left: 2px solid rgba(255,0,0,.8); -} - -pre.should_panic:hover, .information:hover + pre.should_panic { - border-left: 2px solid #f00; -} - -pre.ignore { - border-left: 2px solid rgba(255,142,0,.6); -} - -pre.ignore:hover, .information:hover + pre.ignore { - border-left: 2px solid #ff9200; -} - .tooltip.compile_fail { color: rgba(255,0,0,.8); } -.information > .compile_fail:hover { +.example-wrap:hover pre.compile_fail { + border-left: 2px solid #f00; +} +.example-wrap:hover .tooltip.compile_fail { color: #f00; } +pre.should_panic { + border-left: 2px solid rgba(255,0,0,.8); +} .tooltip.should_panic { color: rgba(255,0,0,.8); } -.information > .should_panic:hover { +.example-wrap:hover pre.should_panic { + border-left: 2px solid #f00; +} +.example-wrap:hover .tooltip.should_panic { color: #f00; } +pre.ignore { + border-left: 2px solid rgba(255,142,0,.6); +} .tooltip.ignore { color: rgba(255,142,0,.6); } -.information > .ignore:hover { +.example-wrap:hover pre.ignore { + border-left: 2px solid #ff9200; +} +.example-wrap:hover .tooltip.ignore { color: #ff9200; } @@ -425,13 +421,10 @@ kbd { } #copy-path { - color: #999; -} -#copy-path > img { - filter: invert(50%); + color: #7f7f7f; } -#copy-path:hover > img { - filter: invert(65%); +#copy-path:hover { + color: #a5a5a5; } #theme-choices { @@ -505,5 +498,5 @@ div.files > .selected { background: #616161; } .toggle-line:hover .toggle-line-inner { - background: ##898989; + background: #898989; } diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css index 4bf411d459a35..ebe1bf3565582 100644 --- a/src/librustdoc/html/static/css/themes/light.css +++ b/src/librustdoc/html/static/css/themes/light.css @@ -199,6 +199,13 @@ details.undocumented > summary::before { color: #999; } +details.rustdoc-toggle > summary:focus::before, +details.rustdoc-toggle > summary:hover::before, +details.undocumented > summary:focus::before, +details.undocumented > summary:hover::before { + color: #000; +} + #crate-search { color: #555; background-color: white; @@ -291,48 +298,42 @@ a.test-arrow:hover{ pre.compile_fail { border-left: 2px solid rgba(255,0,0,.5); } - -pre.compile_fail:hover, .information:hover + pre.compile_fail { - border-left: 2px solid #f00; -} - -pre.should_panic { - border-left: 2px solid rgba(255,0,0,.5); -} - -pre.should_panic:hover, .information:hover + pre.should_panic { - border-left: 2px solid #f00; -} - -pre.ignore { - border-left: 2px solid rgba(255,142,0,.6); -} - -pre.ignore:hover, .information:hover + pre.ignore { - border-left: 2px solid #ff9200; -} - .tooltip.compile_fail { color: rgba(255,0,0,.5); } -.information > .compile_fail:hover { +.example-wrap:hover pre.compile_fail { + border-left: 2px solid #f00; +} +.example-wrap:hover .tooltip.compile_fail { color: #f00; } +pre.should_panic { + border-left: 2px solid rgba(255,0,0,.5); +} .tooltip.should_panic { color: rgba(255,0,0,.5); } -.information > .should_panic:hover { +.example-wrap:hover pre.should_panic { + border-left: 2px solid #f00; +} +.example-wrap:hover .tooltip.should_panic { color: #f00; } +pre.ignore { + border-left: 2px solid rgba(255,142,0,.6); +} .tooltip.ignore { color: rgba(255,142,0,.6); } -.information > .ignore:hover { +.example-wrap:hover pre.ignore { + border-left: 2px solid #ff9200; +} +.example-wrap:hover .tooltip.ignore { color: #ff9200; } @@ -401,6 +402,7 @@ kbd { #theme-picker, #settings-menu, #help-button { border-color: #e0e0e0; background-color: #fff; + color: #000; } #theme-picker:hover, #theme-picker:focus, @@ -410,13 +412,10 @@ kbd { } #copy-path { - color: #999; -} -#copy-path > img { - filter: invert(50%); + color: #7f7f7f; } -#copy-path:hover > img { - filter: invert(35%); +#copy-path:hover { + color: #595959; } #theme-choices { diff --git a/src/librustdoc/html/static/fonts/icons-FontAwesome-LICENSE.txt b/src/librustdoc/html/static/fonts/icons-FontAwesome-LICENSE.txt new file mode 100644 index 0000000000000..79d50e57be4ae --- /dev/null +++ b/src/librustdoc/html/static/fonts/icons-FontAwesome-LICENSE.txt @@ -0,0 +1,43 @@ +Font Awesome Icons: + - U+23F7 (caret-down) + - U+2699 (cog) + - U+26A0 (exclamation-triangle) + - U+1F52C (flask) + - U+24D8 (info-circle) + - U+1F58C (paint-brush) + - U+1F44E (thumbs-down) + +Font Awesome Free License +------------------------- + +Font Awesome Free is free, open source, and GPL friendly. You can use it for +commercial projects, open source projects, or really almost whatever you want. +Full Font Awesome Free license: https://fontawesome.com/license/free. + +# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/) +In the Font Awesome Free download, the CC BY 4.0 license applies to all icons +packaged as SVG and JS file types. + +# Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL) +In the Font Awesome Free download, the SIL OFL license applies to all icons +packaged as web and desktop font files. + +# Code: MIT License (https://opensource.org/licenses/MIT) +In the Font Awesome Free download, the MIT license applies to all non-font and +non-icon files. + +# Attribution +Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font +Awesome Free files already contain embedded comments with sufficient +attribution, so you shouldn't need to do anything additional when using these +files normally. + +We've kept attribution comments terse, so we ask that you do not actively work +to remove them from files, especially code. They're a great way for folks to +learn about Font Awesome. + +# Brand Icons +All brand icons are trademarks of their respective owners. The use of these +trademarks does not indicate endorsement of the trademark holder by Font +Awesome, nor vice versa. **Please do not use brand logos for any purpose except +to represent the company, product, or service to which they refer.** \ No newline at end of file diff --git a/src/librustdoc/html/static/fonts/icons.woff b/src/librustdoc/html/static/fonts/icons.woff new file mode 100644 index 0000000000000..9c69dcd854530 Binary files /dev/null and b/src/librustdoc/html/static/fonts/icons.woff differ diff --git a/src/librustdoc/html/static/fonts/icons.woff2 b/src/librustdoc/html/static/fonts/icons.woff2 new file mode 100644 index 0000000000000..741f5f99bd80f Binary files /dev/null and b/src/librustdoc/html/static/fonts/icons.woff2 differ diff --git a/src/librustdoc/html/static/images/brush.svg b/src/librustdoc/html/static/images/brush.svg deleted file mode 100644 index ea266e856a9d8..0000000000000 --- a/src/librustdoc/html/static/images/brush.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/LICENSE.txt b/src/librustdoc/html/static/images/bundled_into_icon_font/LICENSE.txt new file mode 100644 index 0000000000000..b32d3db9ebca1 --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/LICENSE.txt @@ -0,0 +1,43 @@ +Font Awesome Icons: + - caret-down.svg + - cog.svg + - exclamation-triangle.svg + - flask.svg + - info-circle.svg + - paint-brush.svg + - thumbs-down.svg + +Font Awesome Free License +------------------------- + +Font Awesome Free is free, open source, and GPL friendly. You can use it for +commercial projects, open source projects, or really almost whatever you want. +Full Font Awesome Free license: https://fontawesome.com/license/free. + +# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/) +In the Font Awesome Free download, the CC BY 4.0 license applies to all icons +packaged as SVG and JS file types. + +# Fonts: SIL OFL 1.1 License (https://scripts.sil.org/OFL) +In the Font Awesome Free download, the SIL OFL license applies to all icons +packaged as web and desktop font files. + +# Code: MIT License (https://opensource.org/licenses/MIT) +In the Font Awesome Free download, the MIT license applies to all non-font and +non-icon files. + +# Attribution +Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font +Awesome Free files already contain embedded comments with sufficient +attribution, so you shouldn't need to do anything additional when using these +files normally. + +We've kept attribution comments terse, so we ask that you do not actively work +to remove them from files, especially code. They're a great way for folks to +learn about Font Awesome. + +# Brand Icons +All brand icons are trademarks of their respective owners. The use of these +trademarks does not indicate endorsement of the trademark holder by Font +Awesome, nor vice versa. **Please do not use brand logos for any purpose except +to represent the company, product, or service to which they refer.** \ No newline at end of file diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/README.md b/src/librustdoc/html/static/images/bundled_into_icon_font/README.md new file mode 100644 index 0000000000000..007f6b03daebf --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/README.md @@ -0,0 +1,31 @@ +The SVGs in this directory are bundled into a webfont. This allows them to be easily colored with CSS. + +## Creating the webfont + +Use https://fontello.com + +1. Drag all SVG images in this folder onto the webpage to upload them +2. After upload is complete, select them all by dragging a rectangle over them under "**Custom Icons**" +3. Go to the "Customize Codes" tab +4. We use the following for each icon + +| Icon | Unicode Character | Unicode Code | +|--------------- |-------------------|--------------| +| ![](caret-down.svg) | ⏷ | 23F7 | +| ![](clipboard.svg) | πŸ“‹ | 1F4CB | +| ![](cog.svg) | βš™ | 2699 | +| ![](exclamation-triangle.svg) | ⚠ | 26A0 | +| ![](flask.svg) | πŸ”¬ | 1F52C | +| ![](info-circle.svg) | β“˜ | 24D8 | +| ![](paint-brush.svg) | πŸ–Œ | 1F58C | +| ![](thumbs-down.svg) | πŸ‘Ž | 1F44E | +| ![](toggle-minus.svg) | ⊟ | 229F | +| ![](toggle-plus.svg) | ⊞ | 229E | + +We set these characters to fitting Unicode symbols for the fallback case if a user's browser doesn't support our webfonts or has webfonts disabled. + +5. Click the wrench icon, then go to "Advanced font settings" +6. Select Unicode encoding +7. Set "font name" to `icons` +8. Download webfont +9. Extract `font/icons.woff` and `font/icons.woff2` into `static/fonts` diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/caret-down.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/caret-down.svg new file mode 100644 index 0000000000000..b3ee2ea95198c --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/caret-down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/images/clipboard.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/clipboard.svg similarity index 100% rename from src/librustdoc/html/static/images/clipboard.svg rename to src/librustdoc/html/static/images/bundled_into_icon_font/clipboard.svg diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/cog.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/cog.svg new file mode 100644 index 0000000000000..fb5bd35ac9671 --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/cog.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/exclamation-triangle.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/exclamation-triangle.svg new file mode 100644 index 0000000000000..2ab53271b42a7 --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/exclamation-triangle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/flask.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/flask.svg new file mode 100644 index 0000000000000..c30929ace917e --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/flask.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/info-circle.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/info-circle.svg new file mode 100644 index 0000000000000..a25c1632d11a2 --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/info-circle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/paint-brush.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/paint-brush.svg new file mode 100644 index 0000000000000..01d1c927330ae --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/paint-brush.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/thumbs-down.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/thumbs-down.svg new file mode 100644 index 0000000000000..1cb6e676f2e50 --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/thumbs-down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/toggle-minus.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/toggle-minus.svg new file mode 100644 index 0000000000000..41fa7fbb98a48 --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/toggle-minus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/images/bundled_into_icon_font/toggle-plus.svg b/src/librustdoc/html/static/images/bundled_into_icon_font/toggle-plus.svg new file mode 100644 index 0000000000000..f1e4477efa09c --- /dev/null +++ b/src/librustdoc/html/static/images/bundled_into_icon_font/toggle-plus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/librustdoc/html/static/images/down-arrow.svg b/src/librustdoc/html/static/images/down-arrow.svg deleted file mode 100644 index 35437e77a710c..0000000000000 --- a/src/librustdoc/html/static/images/down-arrow.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/librustdoc/html/static/images/toggle-minus.svg b/src/librustdoc/html/static/images/toggle-minus.svg deleted file mode 100644 index 73154788a0e8e..0000000000000 --- a/src/librustdoc/html/static/images/toggle-minus.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/librustdoc/html/static/images/toggle-plus.svg b/src/librustdoc/html/static/images/toggle-plus.svg deleted file mode 100644 index 08b17033e164b..0000000000000 --- a/src/librustdoc/html/static/images/toggle-plus.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/librustdoc/html/static/images/wheel.svg b/src/librustdoc/html/static/images/wheel.svg deleted file mode 100644 index 01da3b24c7c4f..0000000000000 --- a/src/librustdoc/html/static/images/wheel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 411a94ef2d1c1..ab39609769ab2 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -296,7 +296,7 @@ function hideThemeButtonState() { } }, addCrateDropdown: function(crates) { - var elem = document.getElementById("crate-search"); + var elem = document.getElementById("crate-search").children[0]; if (!elem) { return; @@ -847,9 +847,8 @@ function hideThemeButtonState() { (function() { // To avoid checking on "rustdoc-line-numbers" value on every loop... - var lineNumbersFunc = function() {}; if (getSettingValue("line-numbers") === "true") { - lineNumbersFunc = function(x) { + onEachLazy(document.getElementsByClassName("rust-example-rendered"), function(x) { var count = x.textContent.split("\n").length; var elems = []; for (var i = 0; i < count; ++i) { @@ -859,26 +858,8 @@ function hideThemeButtonState() { addClass(node, "line-number"); node.innerHTML = elems.join("\n"); x.parentNode.insertBefore(node, x); - }; + }); } - onEachLazy(document.getElementsByClassName("rust-example-rendered"), function(e) { - if (hasClass(e, "compile_fail")) { - e.addEventListener("mouseover", function() { - this.parentElement.previousElementSibling.childNodes[0].style.color = "#f00"; - }); - e.addEventListener("mouseout", function() { - this.parentElement.previousElementSibling.childNodes[0].style.color = ""; - }); - } else if (hasClass(e, "ignore")) { - e.addEventListener("mouseover", function() { - this.parentElement.previousElementSibling.childNodes[0].style.color = "#ff9200"; - }); - e.addEventListener("mouseout", function() { - this.parentElement.previousElementSibling.childNodes[0].style.color = ""; - }); - } - lineNumbersFunc(e); - }); }()); function handleClick(id, f) { diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 7c55d10836c45..c6ddb06fb0ca6 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1249,7 +1249,7 @@ window.initSearch = function(rawSearchIndex) { } function getFilterCrates() { - var elem = document.getElementById("crate-search"); + var elem = document.getElementById("crate-search").children[0]; if (elem && elem.value !== "All crates" && hasOwnPropertyRustdoc(rawSearchIndex, elem.value)) @@ -1489,7 +1489,7 @@ window.initSearch = function(rawSearchIndex) { }); - var selectCrate = document.getElementById("crate-search"); + var selectCrate = document.getElementById("crate-search").children[0]; if (selectCrate) { selectCrate.onchange = function() { updateLocalStorage("rustdoc-saved-filter-crate", selectCrate.value); diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index 56c5399d074b6..c5958a677bfa2 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -39,24 +39,6 @@ crate static STORAGE_JS: &str = include_str!("static/js/storage.js"); /// --scrape-examples flag that inserts automatically-found examples of usages of items. crate static SCRAPE_EXAMPLES_JS: &str = include_str!("static/js/scrape-examples.js"); -/// The file contents of `brush.svg`, the icon used for the theme-switch button. -crate static BRUSH_SVG: &[u8] = include_bytes!("static/images/brush.svg"); - -/// The file contents of `wheel.svg`, the icon used for the settings button. -crate static WHEEL_SVG: &[u8] = include_bytes!("static/images/wheel.svg"); - -/// The file contents of `clipboard.svg`, the icon used for the "copy path" button. -crate static CLIPBOARD_SVG: &[u8] = include_bytes!("static/images/clipboard.svg"); - -/// The file contents of `down-arrow.svg`, the icon used for the crate choice combobox. -crate static DOWN_ARROW_SVG: &[u8] = include_bytes!("static/images/down-arrow.svg"); - -/// The file contents of `toggle-minus.svg`, the icon used for opened toggles. -crate static TOGGLE_MINUS_PNG: &[u8] = include_bytes!("static/images/toggle-minus.svg"); - -/// The file contents of `toggle-plus.svg`, the icon used for closed toggles. -crate static TOGGLE_PLUS_PNG: &[u8] = include_bytes!("static/images/toggle-plus.svg"); - /// The contents of `COPYRIGHT.txt`, the license listing for files distributed with documentation /// output. crate static COPYRIGHT: &[u8] = include_bytes!("static/COPYRIGHT.txt"); @@ -74,6 +56,13 @@ crate static RUST_FAVICON_SVG: &[u8] = include_bytes!("static/images/favicon.svg crate static RUST_FAVICON_PNG_16: &[u8] = include_bytes!("static/images/favicon-16x16.png"); crate static RUST_FAVICON_PNG_32: &[u8] = include_bytes!("static/images/favicon-32x32.png"); +/// Files related to the icon font. +crate mod icons { + crate static WOFF: &[u8] = include_bytes!("static/fonts/icons.woff"); + crate static WOFF2: &[u8] = include_bytes!("static/fonts/icons.woff2"); + crate static LICENSE: &[u8] = include_bytes!("static/fonts/icons-FontAwesome-LICENSE.txt"); +} + /// The built-in themes given to every documentation site. crate mod themes { /// The "light" theme, selected by default when no setting is available. Used as the basis for diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index 5c957e4a379a4..ada70cb3dd69f 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -102,17 +102,19 @@