about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-07-21 15:52:46 +0200
committerGitHub <noreply@github.com>2021-07-21 15:52:46 +0200
commite6380a699b150b88e4e0b43ed5e7c3eff438ec58 (patch)
treee1a732c892be1df616dfda30ec358e364df0a282 /src
parent358b2cc0b93d6dd79605983e3978adb4de93b0a1 (diff)
parent3f1a120ba9c5077029ffb2d39d654dd3732314a7 (diff)
downloadrust-e6380a699b150b88e4e0b43ed5e7c3eff438ec58.tar.gz
rust-e6380a699b150b88e4e0b43ed5e7c3eff438ec58.zip
Rollup merge of #87230 - GuillaumeGomez:docblock-table-overflow, r=notriddle
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`
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/static/css/rustdoc.css3
-rw-r--r--src/librustdoc/html/static/css/themes/ayu.css2
-rw-r--r--src/librustdoc/html/static/css/themes/dark.css2
-rw-r--r--src/librustdoc/html/static/css/themes/light.css2
-rw-r--r--src/test/rustdoc-gui/docblock-table-overflow.goml9
-rw-r--r--src/test/rustdoc-gui/src/lib2/lib.rs9
-rw-r--r--src/test/rustdoc-gui/src/lib2/src/lib.rs7
7 files changed, 23 insertions, 11 deletions
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index e608ad05b17..6672093eb7b 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -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 {
diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css
index 8296c3f91ca..354cdd2fb03 100644
--- a/src/librustdoc/html/static/css/themes/ayu.css
+++ b/src/librustdoc/html/static/css/themes/ayu.css
@@ -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;
 }
 
diff --git a/src/librustdoc/html/static/css/themes/dark.css b/src/librustdoc/html/static/css/themes/dark.css
index 599fb942dbe..b4f5a13c815 100644
--- a/src/librustdoc/html/static/css/themes/dark.css
+++ b/src/librustdoc/html/static/css/themes/dark.css
@@ -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;
 }
 
diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css
index 0c2799727f3..29cbcd65ce8 100644
--- a/src/librustdoc/html/static/css/themes/light.css
+++ b/src/librustdoc/html/static/css/themes/light.css
@@ -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;
 }
 
diff --git a/src/test/rustdoc-gui/docblock-table-overflow.goml b/src/test/rustdoc-gui/docblock-table-overflow.goml
new file mode 100644
index 00000000000..9ab7cd0fa07
--- /dev/null
+++ b/src/test/rustdoc-gui/docblock-table-overflow.goml
@@ -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"})
diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs
index cd00348cad3..86ae330e009 100644
--- a/src/test/rustdoc-gui/src/lib2/lib.rs
+++ b/src/test/rustdoc-gui/src/lib2/lib.rs
@@ -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;
+}
diff --git a/src/test/rustdoc-gui/src/lib2/src/lib.rs b/src/test/rustdoc-gui/src/lib2/src/lib.rs
deleted file mode 100644
index 31e1bb209f9..00000000000
--- a/src/test/rustdoc-gui/src/lib2/src/lib.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#[cfg(test)]
-mod tests {
-    #[test]
-    fn it_works() {
-        assert_eq!(2 + 2, 4);
-    }
-}