Skip to content

Commit b01f0d3

Browse files
authored
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.
2 parents 57393be + b76821b commit b01f0d3

File tree

11 files changed

+31
-7
lines changed

11 files changed

+31
-7
lines changed

src/bootstrap/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,8 @@ impl Step for RustdocGUI {
10641064
cargo.env("RUSTDOCFLAGS", "-Zunstable-options --generate-link-to-definition");
10651065
} else if entry.file_name() == "scrape_examples" {
10661066
cargo.arg("-Zrustdoc-scrape-examples");
1067+
} else if entry.file_name() == "extend_css" {
1068+
cargo.env("RUSTDOCFLAGS", &format!("--extend-css extra.css"));
10671069
}
10681070
builder.run(&mut cargo);
10691071
}

src/doc/rustdoc/src/command-line-arguments.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,7 @@ $ rustdoc src/lib.rs --extend-css extra.css
320320
```
321321

322322
With this flag, the contents of the files you pass are included at the bottom
323-
of Rustdoc's `theme.css` file.
324-
325-
While this flag is stable, the contents of `theme.css` are not, so be careful!
326-
Updates may break your theme extensions.
323+
of the `theme.css` file.
327324

328325
## `--sysroot`: override the system root
329326

src/librustdoc/html/templates/page.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
</noscript> {# #}
6565
{% if layout.css_file_extension.is_some() %}
6666
<link rel="stylesheet" {#+ #}
67-
href="{{static_root_path|safe}}theme{{page.resource_suffix}}.css"> {# #}
67+
href="{{page.root_path|safe}}theme{{page.resource_suffix}}.css"> {# #}
6868
{% endif %}
6969
{% if !layout.favicon.is_empty() %}
7070
<link rel="icon" href="{{layout.favicon}}"> {# #}

tests/rustdoc-gui/extend-css.goml

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

tests/rustdoc-gui/search-filter.goml

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ press-key: "ArrowDown"
1616
press-key: "ArrowDown"
1717
press-key: "ArrowDown"
1818
press-key: "ArrowDown"
19+
press-key: "ArrowDown"
1920
press-key: "Enter"
2021
// Waiting for the search results to appear...
2122
wait-for: "#search-tabs"
@@ -41,6 +42,7 @@ press-key: "ArrowUp"
4142
press-key: "ArrowUp"
4243
press-key: "ArrowUp"
4344
press-key: "ArrowUp"
45+
press-key: "ArrowUp"
4446
press-key: "Enter"
4547
// Waiting for the search results to appear...
4648
wait-for: "#search-tabs"

tests/rustdoc-gui/sidebar-source-code.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
7373
// Only "another_folder" should be "open" in "lib2".
7474
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
7575
// All other trees should be collapsed.
76-
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8)
76+
assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 9)
7777

7878
// We now switch to mobile mode.
7979
set-window-size: (600, 600)

tests/rustdoc-gui/source-code-page.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ assert: ".source-sidebar-expanded"
102102

103103
// We check that the first entry of the sidebar is collapsed
104104
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
105-
assert-text: ("#source-sidebar details:first-of-type > summary", "http")
105+
assert-text: ("#source-sidebar details:first-of-type > summary", "extend_css")
106106
// We now click on it.
107107
click: "#source-sidebar details:first-of-type > summary"
108108
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "extend_css"
7+
version = "0.1.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "extend_css"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
[lib]
7+
path = "lib.rs"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.extend {
2+
color: red !important;
3+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//! <div class="extend">text in red</div>

0 commit comments

Comments
 (0)