Rollup merge of #110235 - GuillaumeGomez:fix-extend-css, r=notriddle

Fix `--extend-css` option

Fixes #110002.

The file was generated in the wrong folder so I moved it into `static.files` as it made more sense to have there instead of changing the path in the templates.

I also added a GUI test to ensure that this option won't break unexpectedly again.
This commit is contained in:
Matthias Krüger 2023-04-12 22:04:35 +02:00 committed by GitHub
commit b01f0d3928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 31 additions and 7 deletions

View File

@ -1064,6 +1064,8 @@ fn run(self, builder: &Builder<'_>) {
cargo.env("RUSTDOCFLAGS", "-Zunstable-options --generate-link-to-definition");
} else if entry.file_name() == "scrape_examples" {
cargo.arg("-Zrustdoc-scrape-examples");
} else if entry.file_name() == "extend_css" {
cargo.env("RUSTDOCFLAGS", &format!("--extend-css extra.css"));
}
builder.run(&mut cargo);
}

View File

@ -320,10 +320,7 @@ $ rustdoc src/lib.rs --extend-css extra.css
```
With this flag, the contents of the files you pass are included at the bottom
of Rustdoc's `theme.css` file.
While this flag is stable, the contents of `theme.css` are not, so be careful!
Updates may break your theme extensions.
of the `theme.css` file.
## `--sysroot`: override the system root

View File

@ -64,7 +64,7 @@
</noscript> {# #}
{% if layout.css_file_extension.is_some() %}
<link rel="stylesheet" {#+ #}
href="{{static_root_path|safe}}theme{{page.resource_suffix}}.css"> {# #}
href="{{page.root_path|safe}}theme{{page.resource_suffix}}.css"> {# #}
{% endif %}
{% if !layout.favicon.is_empty() %}
<link rel="icon" href="{{layout.favicon}}"> {# #}

View File

@ -0,0 +1,5 @@
// Test to ensure that the `--extend-css` option is working as expected.
go-to: "file://" + |DOC_PATH| + "/extend_css/index.html"
show-text: true
// The text from the `.extend` element should be red.
assert-css: (".extend", {"color": "rgb(255, 0, 0)"})

View File

@ -16,6 +16,7 @@ press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"
@ -41,6 +42,7 @@ press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"

View File

@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
// Only "another_folder" should be "open" in "lib2".
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
// All other trees should be collapsed.
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8)
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 9)
// We now switch to mobile mode.
set-window-size: (600, 600)

View File

@ -102,7 +102,7 @@ assert: ".source-sidebar-expanded"
// We check that the first entry of the sidebar is collapsed
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
assert-text: ("#source-sidebar details:first-of-type > summary", "http")
assert-text: ("#source-sidebar details:first-of-type > summary", "extend_css")
// We now click on it.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "extend_css"
version = "0.1.0"

View File

@ -0,0 +1,7 @@
[package]
name = "extend_css"
version = "0.1.0"
edition = "2018"
[lib]
path = "lib.rs"

View File

@ -0,0 +1,3 @@
.extend {
color: red !important;
}

View File

@ -0,0 +1 @@
//! <div class="extend">text in red</div>