Skip to content

Commit 4a5cece

Browse files
authored
Rollup merge of #106027 - notriddle:notriddle/more-scraped-examples-inner, r=GuillaumeGomez
rustdoc: simplify CSS and DOM for more-scraped-examples This gets rid of the more-scraped-examples-inner wrapper, instead nesting the children directly and using absolute positioning for the toggle line.
2 parents 273fe60 + 2b661c3 commit 4a5cece

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

src/librustdoc/html/render/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -3005,8 +3005,7 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite
30053005
</summary>\
30063006
<div class=\"hide-more\">Hide additional examples</div>\
30073007
<div class=\"more-scraped-examples\">\
3008-
<div class=\"toggle-line\"><div class=\"toggle-line-inner\"></div></div>\
3009-
<div class=\"more-scraped-examples-inner\">"
3008+
<div class=\"toggle-line\"><div class=\"toggle-line-inner\"></div></div>"
30103009
);
30113010

30123011
// Only generate inline code for MAX_FULL_EXAMPLES number of examples. Otherwise we could
@@ -3030,7 +3029,7 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite
30303029
write!(w, "</ul></div>");
30313030
}
30323031

3033-
write!(w, "</div></div></details>");
3032+
write!(w, "</div></details>");
30343033
}
30353034

30363035
write!(w, "</div>");

src/librustdoc/html/static/css/rustdoc.css

+6-11
Original file line numberDiff line numberDiff line change
@@ -1991,20 +1991,15 @@ in storage.js
19911991
}
19921992

19931993
.more-scraped-examples {
1994-
margin-left: 5px;
1995-
display: flex;
1996-
flex-direction: row;
1997-
}
1998-
1999-
.more-scraped-examples-inner {
2000-
/* 20px is width of toggle-line + toggle-line-inner */
2001-
width: calc(100% - 20px);
1994+
margin-left: 25px;
1995+
position: relative;
20021996
}
20031997

20041998
.toggle-line {
2005-
align-self: stretch;
2006-
margin-right: 10px;
2007-
margin-top: 5px;
1999+
position: absolute;
2000+
top: 5px;
2001+
bottom: 0;
2002+
right: calc(100% + 10px);
20082003
padding: 0 4px;
20092004
cursor: pointer;
20102005
}

src/test/rustdoc-gui/scrape-examples-layout.goml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ assert-property-false: (
1010
// Check that examples with very long lines have the same width as ones that don't.
1111
store-property: (
1212
clientWidth,
13-
".more-scraped-examples .scraped-example:nth-child(1) .code-wrapper .src-line-numbers",
13+
".more-scraped-examples .scraped-example:nth-child(2) .code-wrapper .src-line-numbers",
1414
"clientWidth"
1515
)
1616

1717
assert-property: (
18-
".more-scraped-examples .scraped-example:nth-child(2) .code-wrapper .src-line-numbers",
18+
".more-scraped-examples .scraped-example:nth-child(3) .code-wrapper .src-line-numbers",
1919
{"clientWidth": |clientWidth|}
2020
)
2121

2222
assert-property: (
23-
".more-scraped-examples .scraped-example:nth-child(3) .code-wrapper .src-line-numbers",
23+
".more-scraped-examples .scraped-example:nth-child(4) .code-wrapper .src-line-numbers",
2424
{"clientWidth": |clientWidth|}
2525
)
2626

2727
assert-property: (
28-
".more-scraped-examples .scraped-example:nth-child(4) .code-wrapper .src-line-numbers",
28+
".more-scraped-examples .scraped-example:nth-child(5) .code-wrapper .src-line-numbers",
2929
{"clientWidth": |clientWidth|}
3030
)
3131

3232
assert-property: (
33-
".more-scraped-examples .scraped-example:nth-child(5) .code-wrapper .src-line-numbers",
33+
".more-scraped-examples .scraped-example:nth-child(6) .code-wrapper .src-line-numbers",
3434
{"clientWidth": |clientWidth|}
3535
)

0 commit comments

Comments
 (0)