Skip to content

Commit b320300

Browse files
authored
Rollup merge of #161340 - notriddle:rustdoc-overflow, r=lolbinarycat,GuillaumeGomez
rustdoc: enable scrolling only on table/code This is a fix for a problem that hit `<ol>`, where the digits were truncated at the edge of the scroll container. Fixes #161144 <img width="1552" height="923" alt="Screenshot 2026-08-18 at 21 08 12" src="https://github.com/user-attachments/assets/4825a756-0068-42e8-99f2-8a57cc17f234" /> None of this code was written with an LLM, but, supposedly, one was used in the above issue thread for root cause analysis.
2 parents e0949ac + 9549cb7 commit b320300

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎src/librustdoc/html/markdown.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for TableWrapper<'a, I> {
527527
Some(match event {
528528
Event::Start(Tag::Table(t)) => {
529529
self.stored_events.push_back(Event::Start(Tag::Table(t)));
530-
Event::Html(CowStr::Borrowed("<div>"))
530+
Event::Html(CowStr::Borrowed(r#"<div class="table">"#))
531531
}
532532
Event::End(TagEnd::Table) => {
533533
self.stored_events.push_back(Event::Html(CowStr::Borrowed("</div>")));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ rustdoc-topbar {
10981098
position: relative;
10991099
}
11001100

1101-
.docblock > :not(.more-examples-toggle):not(.example-wrap) {
1101+
.docblock pre, .docblock div.table {
11021102
max-width: 100%;
11031103
overflow-x: auto;
11041104
}

‎tests/rustdoc-gui/list-margins.goml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This test ensures that the documentation list markers are correctly placed.
2-
// It also serves as a regression test for <https://github.com/rust-lang/rust/issues/130622>.
2+
// It also serves as a regression test for <https://github.com/rust-lang/rust/issues/130622>
3+
// and <https://github.com/rust-lang/rust/issues/161144>
34

45
go-to: "file://" + |DOC_PATH| + "/test_docs/long_list/index.html"
56
show-text: true
@@ -9,3 +10,12 @@ assert-css: (".docblock li p:not(last-child)", {"margin-bottom": "4.8px"})
910
assert-css: (".docblock li p + p:last-child", {"margin-bottom": "0px"})
1011
// 0.4em
1112
assert-css: (".docblock li", {"margin-bottom": "6.4px"})
13+
14+
// check that the list is allowed to overflow
15+
assert-css: ("details.toggle", {"overflow": "visible"})
16+
assert-css: (".docblock", {"overflow": "visible"})
17+
assert-css: (".docblock ol", {"overflow": "visible"})
18+
assert-css: (".docblock ol li", {"overflow": "visible"})
19+
store-position: ("main", {"x": main_x})
20+
store-position: (".docblock ol li::marker", {"x": marker_x})
21+
assert: |main_x| <= |marker_x|

‎tests/rustdoc-gui/src/test_docs/lib.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,12 @@ pub mod long_list {
679679
//!
680680
//! Another list:
681681
//!
682-
//! * [`TryFromBytes`](#a) indicates that a type may safely be converted from certain byte
683-
//! sequence (conditional on runtime checks)
684-
//! * [`FromZeros`](#a) indicates that a sequence of zero bytes represents a valid instance of
685-
//! a type
686-
//! * [`FromBytes`](#a) indicates that a type may safely be converted from an arbitrary byte
687-
//! sequence
682+
//! 100. [`TryFromBytes`](#a) indicates that a type may safely be converted from certain byte
683+
//! sequence (conditional on runtime checks)
684+
//! 101. [`FromZeros`](#a) indicates that a sequence of zero bytes represents a valid instance of
685+
//! a type
686+
//! 102. [`FromBytes`](#a) indicates that a type may safely be converted from an arbitrary byte
687+
//! sequence
688688
}
689689

690690
pub struct ImplDoc;

0 commit comments

Comments
 (0)