Consistentize the system for image URLs in CSS.
This commit is contained in:
parent
f0683f98fa
commit
d9afca5808
@ -67,11 +67,12 @@ crate fn render<T: Print, S: Print>(
|
|||||||
) -> String {
|
) -> String {
|
||||||
let static_root_path = page.get_static_root_path();
|
let static_root_path = page.get_static_root_path();
|
||||||
let krate_with_trailing_slash = ensure_trailing_slash(&layout.krate).to_string();
|
let krate_with_trailing_slash = ensure_trailing_slash(&layout.krate).to_string();
|
||||||
let themes = style_files
|
let mut themes: Vec<String> = style_files
|
||||||
.iter()
|
.iter()
|
||||||
.map(StylePath::basename)
|
.map(StylePath::basename)
|
||||||
.collect::<Result<_, Error>>()
|
.collect::<Result<_, Error>>()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
themes.sort();
|
||||||
let rustdoc_version = rustc_interface::util::version_str().unwrap_or("unknown version");
|
let rustdoc_version = rustc_interface::util::version_str().unwrap_or("unknown version");
|
||||||
let content = Buffer::html().to_display(t); // Note: This must happen before making the sidebar.
|
let content = Buffer::html().to_display(t); // Note: This must happen before making the sidebar.
|
||||||
let sidebar = Buffer::html().to_display(sidebar);
|
let sidebar = Buffer::html().to_display(sidebar);
|
||||||
|
@ -181,42 +181,34 @@ pub(super) fn write_shared(
|
|||||||
cx.write_shared(SharedResource::InvocationSpecific { basename: p }, content, &options.emit)
|
cx.write_shared(SharedResource::InvocationSpecific { basename: p }, content, &options.emit)
|
||||||
};
|
};
|
||||||
|
|
||||||
fn add_background_image_to_css(
|
// Given "foo.svg", return e.g. "url(\"foo1.58.0.svg\")"
|
||||||
cx: &Context<'_>,
|
fn ver_url(cx: &Context<'_>, basename: &'static str) -> String {
|
||||||
css: &mut String,
|
format!(
|
||||||
rule: &str,
|
"url(\"{}\")",
|
||||||
file: &'static str,
|
SharedResource::ToolchainSpecific { basename }
|
||||||
) {
|
|
||||||
css.push_str(&format!(
|
|
||||||
"{} {{ background-image: url({}); }}",
|
|
||||||
rule,
|
|
||||||
SharedResource::ToolchainSpecific { basename: file }
|
|
||||||
.path(cx)
|
.path(cx)
|
||||||
.file_name()
|
.file_name()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all the static files. These may already exist, but we just
|
// We use the AUTOREPLACE mechanism to inject into our static JS and CSS certain
|
||||||
// overwrite them anyway to make sure that they're fresh and up-to-date.
|
// values that are only known at doc build time. Since this mechanism is somewhat
|
||||||
let mut rustdoc_css = static_files::RUSTDOC_CSS.to_owned();
|
// surprising when reading the code, please limit it to rustdoc.css.
|
||||||
add_background_image_to_css(
|
write_minify(
|
||||||
|
"rustdoc.css",
|
||||||
|
static_files::RUSTDOC_CSS
|
||||||
|
.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")),
|
||||||
cx,
|
cx,
|
||||||
&mut rustdoc_css,
|
options,
|
||||||
"details.undocumented[open] > summary::before, \
|
)?;
|
||||||
details.rustdoc-toggle[open] > summary::before, \
|
|
||||||
details.rustdoc-toggle[open] > summary.hideme::before",
|
|
||||||
"toggle-minus.svg",
|
|
||||||
);
|
|
||||||
add_background_image_to_css(
|
|
||||||
cx,
|
|
||||||
&mut rustdoc_css,
|
|
||||||
"details.undocumented > summary::before, details.rustdoc-toggle > summary::before",
|
|
||||||
"toggle-plus.svg",
|
|
||||||
);
|
|
||||||
write_minify("rustdoc.css", rustdoc_css, cx, options)?;
|
|
||||||
|
|
||||||
// Add all the static files. These may already exist, but we just
|
// Add all the static files. These may already exist, but we just
|
||||||
// overwrite them anyway to make sure that they're fresh and up-to-date.
|
// overwrite them anyway to make sure that they're fresh and up-to-date.
|
||||||
|
@ -824,6 +824,7 @@ h2.small-section-header > .anchor {
|
|||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
background-size: 20px;
|
background-size: 20px;
|
||||||
background-position: calc(100% - 1px) 56%;
|
background-position: calc(100% - 1px) 56%;
|
||||||
|
background-image: /* AUTOREPLACE: */url("down-arrow.svg");
|
||||||
}
|
}
|
||||||
.search-container > .top-button {
|
.search-container > .top-button {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -1604,6 +1605,16 @@ details.rustdoc-toggle[open] > summary.hideme > span {
|
|||||||
display: none;
|
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.rustdoc-toggle[open] > summary::before,
|
details.rustdoc-toggle[open] > summary::before,
|
||||||
details.rustdoc-toggle[open] > summary.hideme::before {
|
details.rustdoc-toggle[open] > summary.hideme::before {
|
||||||
width: 17px;
|
width: 17px;
|
||||||
|
@ -58,8 +58,8 @@ function resourcePath(basename, extension) {
|
|||||||
(function () {
|
(function () {
|
||||||
window.rootPath = getVar("root-path");
|
window.rootPath = getVar("root-path");
|
||||||
window.currentCrate = getVar("current-crate");
|
window.currentCrate = getVar("current-crate");
|
||||||
window.searchJS = resourcePath("search", "js");
|
window.searchJS = resourcePath("search", ".js");
|
||||||
window.searchIndexJS = resourcePath("search-index", "js");
|
window.searchIndexJS = resourcePath("search-index", ".js");
|
||||||
var sidebarVars = document.getElementById("sidebar-vars");
|
var sidebarVars = document.getElementById("sidebar-vars");
|
||||||
if (sidebarVars) {
|
if (sidebarVars) {
|
||||||
window.sidebarCurrent = {
|
window.sidebarCurrent = {
|
||||||
|
@ -58,11 +58,6 @@
|
|||||||
href="{{static_root_path | safe}}favicon{{page.resource_suffix}}.svg"> {#- -#}
|
href="{{static_root_path | safe}}favicon{{page.resource_suffix}}.svg"> {#- -#}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{{- layout.external_html.in_header | safe -}}
|
{{- layout.external_html.in_header | safe -}}
|
||||||
<style type="text/css"> {#- -#}
|
|
||||||
#crate-search{ {#- -#}
|
|
||||||
background-image:url("{{static_root_path | safe}}down-arrow{{page.resource_suffix}}.svg"); {#- -#}
|
|
||||||
} {#- -#}
|
|
||||||
</style> {#- -#}
|
|
||||||
</head> {#- -#}
|
</head> {#- -#}
|
||||||
<body class="rustdoc {{page.css_class}}"> {#- -#}
|
<body class="rustdoc {{page.css_class}}"> {#- -#}
|
||||||
<!--[if lte IE 11]> {#- -#}
|
<!--[if lte IE 11]> {#- -#}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// @has static_root_path/struct.SomeStruct.html
|
// @has static_root_path/struct.SomeStruct.html
|
||||||
// @matches - '"/cache/main\.js"'
|
// @matches - '"/cache/main\.js"'
|
||||||
// @!matches - '"\.\./main\.js"'
|
// @!matches - '"\.\./main\.js"'
|
||||||
// @matches - '"\.\./search-index\.js"'
|
// @matches - 'data-root-path="\.\./"'
|
||||||
// @!matches - '"/cache/search-index\.js"'
|
// @!matches - '"/cache/search-index\.js"'
|
||||||
pub struct SomeStruct;
|
pub struct SomeStruct;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user