Skip to content

Commit

Permalink
Rollup merge of #87230 - GuillaumeGomez:docblock-table-overflow, r=no…
Browse files Browse the repository at this point in the history
…triddle

Fix docblock <table> overflow

Before:

![Screenshot from 2021-07-18 00-05-23](https://user-images.githubusercontent.com/3050060/126050272-ce08bc5f-74ff-4135-bc12-d708d87470cc.png)

After:

![Screenshot from 2021-07-18 00-03-55](https://user-images.githubusercontent.com/3050060/126050273-42f41b4d-ad57-4a87-91de-18e63f8504ec.png)

cc `@SergioBenitez`

r? `@notriddle`
  • Loading branch information
GuillaumeGomez committed Jul 21, 2021
2 parents 358b2cc + 3f1a120 commit e6380a6
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ nav.sub {
.docblock table {
margin: .5em 0;
width: calc(100% - 2px);
border: 1px dashed;
overflow-x: auto;
display: block;
}

.docblock table td {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pre, .rustdoc.source .example-wrap {
border-bottom-color: #5c6773;
}

.docblock table, .docblock table td, .docblock table th {
.docblock table td, .docblock table th {
border-color: #5c6773;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pre, .rustdoc.source .example-wrap {
border-bottom-color: #DDD;
}

.docblock table, .docblock table td, .docblock table th {
.docblock table td, .docblock table th {
border-color: #ddd;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pre, .rustdoc.source .example-wrap {
border-bottom-color: #ddd;
}

.docblock table, .docblock table td, .docblock table th {
.docblock table td, .docblock table th {
border-color: #ddd;
}

Expand Down
9 changes: 9 additions & 0 deletions src/test/rustdoc-gui/docblock-table-overflow.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This test ensures that the type declaration content overflow is handled inside the <pre> directly.
goto: file://|DOC_PATH|/lib2/long_table/struct.Foo.html
// We set a fixed size so there is no chance of "random" resize.
size: (1100, 800)
// Logically, the ".docblock" and the "<p>" should have the same scroll width.
compare-elements-property: (".top-doc .docblock", ".top-doc .docblock > p", ["scrollWidth"])
assert-property: (".top-doc .docblock", {"scrollWidth": "816"})
// However, since there is overflow in the <table>, its scroll width is bigger.
assert-property: (".top-doc .docblock table", {"scrollWidth": "1573"})
9 changes: 9 additions & 0 deletions src/test/rustdoc-gui/src/lib2/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,12 @@ pub mod long_trait {
pub trait ALongNameBecauseItHelpsTestingTheCurrentProblem: DerefMut<Target = u32>
+ From<u128> + Send + Sync + AsRef<str> + 'static {}
}

pub mod long_table {
/// | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two | This::is::a::kinda::very::long::header::number::one | This::is::a::kinda::very::long::header::number::two |
/// | ----------- | ----------- | ----------- | ----------- |
/// | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two | This::is::a::kinda::long::content::number::one | This::is::a::kinda::very::long::content::number::two |
///
/// I wanna sqdkfnqds f dsqf qds f dsqf dsq f dsq f qds f qds f qds f dsqq f dsf sqdf dsq fds f dsq f dq f ds fq sd fqds f dsq f sqd fsq df sd fdsqfqsd fdsq f dsq f dsqfd s dfq
pub struct Foo;
}
7 changes: 0 additions & 7 deletions src/test/rustdoc-gui/src/lib2/src/lib.rs

This file was deleted.

0 comments on commit e6380a6

Please sign in to comment.