Skip to content

Commit d15cf36

Browse files
authored
Rollup merge of #135998 - GuillaumeGomez:fix-trait-items-mobile-indent, r=notriddle
[rustdoc] Fix indent of trait items on mobile Before: ![Screenshot From 2025-01-24 15-38-53](https://github.com/user-attachments/assets/f7738ff8-92b6-4aca-8a66-2d3618c54572) After: ![Screenshot From 2025-01-24 15-38-37](https://github.com/user-attachments/assets/0a19dc7e-dddd-4cd5-b087-1915e152d7c1) Seems like we forgot them when we did #131718. Can be tested [here](https://rustdoc.crud.net/imperio/fix-trait-items-mobile-indent/foo/trait.T.html). r? `@notriddle`
2 parents 99e34a4 + caacb04 commit d15cf36

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed

Diff for: src/librustdoc/html/static/css/rustdoc.css

+7-3
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,8 @@ details.toggle > summary:not(.hideme)::before {
21662166
top: 4px;
21672167
}
21682168

2169-
.impl-items > details.toggle > summary:not(.hideme)::before {
2169+
.impl-items > details.toggle > summary:not(.hideme)::before,
2170+
#main-content > .methods > details.toggle > summary:not(.hideme)::before {
21702171
position: absolute;
21712172
left: -24px;
21722173
}
@@ -2176,7 +2177,9 @@ details.toggle > summary:not(.hideme)::before {
21762177
.impl-items > *:not(.item-info),
21772178
/* We also indent the first top doc comment the same to still keep an indent on the
21782179
doc block while aligning it with the impl block items. */
2179-
.implementors-toggle > .docblock {
2180+
.implementors-toggle > .docblock,
2181+
/* We indent trait items as well. */
2182+
#main-content > .methods > :not(.item-info) {
21802183
margin-left: var(--impl-items-indent);
21812184
}
21822185

@@ -2508,7 +2511,8 @@ in src-script.js and main.js
25082511
margin-left: 10px;
25092512
}
25102513

2511-
.impl-items > details.toggle > summary:not(.hideme)::before {
2514+
.impl-items > details.toggle > summary:not(.hideme)::before,
2515+
#main-content > .methods > details.toggle > summary:not(.hideme)::before {
25122516
left: -20px;
25132517
}
25142518

Diff for: tests/rustdoc-gui/search-tab.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ call-function: ("check-colors", {
7878
set-window-size: (851, 600)
7979

8080
// Check the size and count in tabs
81-
assert-text: ("#search-tabs > button:nth-child(1) > .count", " (26) ")
81+
assert-text: ("#search-tabs > button:nth-child(1) > .count", " (27) ")
8282
assert-text: ("#search-tabs > button:nth-child(2) > .count", " (7)  ")
8383
assert-text: ("#search-tabs > button:nth-child(3) > .count", " (0)  ")
8484
store-property: ("#search-tabs > button:nth-child(1)", {"offsetWidth": buttonWidth})

Diff for: tests/rustdoc-gui/src/test_docs/lib.rs

+22
Original file line numberDiff line numberDiff line change
@@ -691,3 +691,25 @@ impl ImplDoc {
691691
impl ImplDoc {
692692
pub fn bar5() {}
693693
}
694+
695+
pub trait ItemsTrait {
696+
/// You want doc, here is doc!
697+
///
698+
/// blablala
699+
type F;
700+
701+
/// You want doc, here is doc!
702+
///
703+
/// blablala
704+
const X: u32;
705+
706+
/// You want doc, here is doc!
707+
///
708+
/// blablala
709+
fn foo() {}
710+
711+
/// You want doc, here is doc!
712+
///
713+
/// blablala
714+
fn bar();
715+
}

Diff for: tests/rustdoc-gui/toggle-docs-mobile.goml

+26
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,29 @@ assert-attribute: (".top-doc", {"open": ""})
3131
// To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
3232
click: (3, 270)
3333
assert-attribute: (".top-doc", {"open": ""})
34+
35+
// Same check on trait items.
36+
fail-on-request-error: false // To prevent downloads errors on "trait.impl/test_docs/trait.ItemsTrait.js"
37+
go-to: "file://" + |DOC_PATH| + "/test_docs/trait.ItemsTrait.html"
38+
39+
define-function: (
40+
"check-trait-item",
41+
[nth, text],
42+
block {
43+
store-value: (selector, ".methods:nth-of-type(" + |nth| + ") > details summary")
44+
assert-text: (|selector| + " h4", |text|)
45+
assert-position: (
46+
|selector| + "::before",
47+
{"x": 6},
48+
)
49+
},
50+
)
51+
52+
// Assert the position of the toggle on an associated const.
53+
call-function: ("check-trait-item", {"nth": 2, "text": "const X: u32"})
54+
// Assert the position of the toggle on an associated type.
55+
call-function: ("check-trait-item", {"nth": 3, "text": "type F"})
56+
// Assert the position of the toggle on an associated required method.
57+
call-function: ("check-trait-item", {"nth": 4, "text": "fn bar()"})
58+
// Assert the position of the toggle on an associated provided method.
59+
call-function: ("check-trait-item", {"nth": 5, "text": "fn foo()"})

0 commit comments

Comments
 (0)