Skip to content

Commit 021b8ff

Browse files
Add tests to ensure that <table> don't break doc blocks width anymore
1 parent 32188d7 commit 021b8ff

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/test/rustdoc-gui/docblock-table-overflow.goml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ compare-elements-property: (".top-doc .docblock", ".top-doc .docblock > p", ["sc
77
assert-property: (".top-doc .docblock", {"scrollWidth": "816"})
88
// However, since there is overflow in the <table>, its scroll width is bigger.
99
assert-property: (".top-doc .docblock table", {"scrollWidth": "1573"})
10+
11+
// Checking it works on other doc blocks as well...
12+
13+
// Logically, the ".docblock" and the "<p>" should have the same scroll width.
14+
compare-elements-property: ("#implementations + details .docblock", "#implementations + details .docblock > p", ["scrollWidth"])
15+
assert-property: ("#implementations + details .docblock", {"scrollWidth": "816"})
16+
// However, since there is overflow in the <table>, its scroll width is bigger.
17+
assert-property: ("#implementations + details .docblock table", {"scrollWidth": "1573"})

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ pub mod long_table {
6767
///
6868
/// 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
6969
pub struct Foo;
70+
71+
/// | 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 |
72+
/// | ----------- | ----------- | ----------- | ----------- |
73+
/// | 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 |
74+
///
75+
/// 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
76+
impl Foo {
77+
pub fn foo(&self) {}
78+
}
7079
}
7180

7281
pub mod summary_table {

src/test/rustdoc/table-in-docblock.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![crate_name = "foo"]
2+
3+
// @has foo/struct.Foo.html
4+
// @count - '//*[@class="docblock"]/div/table' 2
5+
// @!has - '//*[@class="docblock"]/table'
6+
/// | hello | hello2 |
7+
/// | ----- | ------ |
8+
/// | data | data2 |
9+
pub struct Foo;
10+
11+
impl Foo {
12+
/// | hello | hello2 |
13+
/// | ----- | ------ |
14+
/// | data | data2 |
15+
pub fn foo(&self) {}
16+
}

0 commit comments

Comments
 (0)