Skip to content

Commit 9aa3180

Browse files
authored
Rollup merge of rust-lang#102100 - GuillaumeGomez:stab-in-docblocks, r=notriddle
Prevent usage of .stab elements to create scrollable areas in doc blocks Fixes rust-lang#101874. You can test it online [here](https://rustdoc.crud.net/imperio/stab-in-doblocks/foo/index.html). r? `@notriddle`
2 parents 3c6dbf9 + 6069f71 commit 9aa3180

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,12 @@ so that we can apply CSS-filters to change the arrow color in themes */
10881088
margin-right: 0.3rem;
10891089
}
10901090

1091+
/* This is to prevent the `.stab` elements to overflow the .docblock elements. */
1092+
.docblock .stab {
1093+
padding: 0 0.125em;
1094+
margin-bottom: 0;
1095+
}
1096+
10911097
/* Black one-pixel outline around emoji shapes */
10921098
.emoji {
10931099
text-shadow:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// This test checks that using `.stab` attributes in `.docblock` elements doesn't
2+
// create scrollable paragraphs.
3+
goto: file://|DOC_PATH|/test_docs/index.html
4+
// Needs the text to be display to check for scrollable content.
5+
show-text: true
6+
size: (786, 600)
7+
// Confirms that there 3 paragraphs.
8+
assert-count: (".top-doc .docblock p", 3)
9+
// Checking that there is no scrollable content.
10+
assert-property: (
11+
".top-doc .docblock p:nth-of-type(1)",
12+
{"scrollHeight": "120", "clientHeight": "120", "scrollWidth": "502", "clientWidth": "502"},
13+
)
14+
assert-property: (
15+
".top-doc .docblock p:nth-of-type(2)",
16+
{"scrollHeight": "48", "clientHeight": "48", "scrollWidth": "502", "clientWidth": "502"},
17+
)
18+
assert-property: (
19+
".top-doc .docblock p:nth-of-type(3)",
20+
{"scrollHeight": "48", "clientHeight": "48", "scrollWidth": "502", "clientWidth": "502"},
21+
)

src/test/rustdoc-gui/src/test_docs/lib.rs

+18
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
#![feature(rustdoc_internals)]
77
#![feature(doc_cfg)]
88

9+
/*!
10+
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
11+
this crate even more!
12+
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
13+
this crate even more!
14+
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
15+
this crate even more!
16+
17+
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
18+
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
19+
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
20+
21+
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
22+
</span>.
23+
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
24+
</span>.
25+
*/
26+
927
use std::convert::AsRef;
1028
use std::fmt;
1129

0 commit comments

Comments
 (0)