Skip to content

Commit a09e8c5

Browse files
committed
rustdoc: clean up docblock table CSS
* The rule `display: block` had no noticeable effect. Technically, because markdown tables have a tbody and thead, they get wrapped in an [anonymous table box] in the CSS tree, nested within the `<table>` element's block layout box. This rule was added in rust-lang#87230 to make the table side-scrolling, but this same issue was doubly fixed in rust-lang#88742 by wrapping it in an explicit `<div>` tag. Since accessibility advocates recommend the wrapper div over marking the table as `display: block`, we'll stick with that. https://adrianroselli.com/2020/11/under-engineered-responsive-tables.html * The rule `width: calc(100% - 2px)` had no visible effect, because the anonymous table box was not affected. * The style is tweaked to basically be the same style GitHub uses. In particular, it adds zebra stripes, and removes dotted borders. [anonymous table box]: https://www.w3.org/TR/CSS2/tables.html#anonymous-boxes
1 parent b28d30e commit a09e8c5

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

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

+4-10
Original file line numberDiff line numberDiff line change
@@ -631,22 +631,16 @@ pre, .rustdoc.source .example-wrap {
631631

632632
.docblock table {
633633
margin: .5em 0;
634-
width: calc(100% - 2px);
635-
overflow-x: auto;
636-
display: block;
637634
border-collapse: collapse;
638635
}
639636

640-
.docblock table td {
637+
.docblock table td, .docblock table th {
641638
padding: .5em;
642-
border: 1px dashed var(--border-color);
643-
vertical-align: top;
639+
border: 1px solid var(--border-color);
644640
}
645641

646-
.docblock table th {
647-
padding: .5em;
648-
text-align: left;
649-
border: 1px solid var(--border-color);
642+
.docblock table tr:nth-child(2n) {
643+
background: var(--table-alt-row-background-color);
650644
}
651645

652646
/* Shift "where ..." part of method or fn definition down a line */

src/librustdoc/html/static/css/themes/ayu.css

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Original by Dempfi (https://github.com/dempfi/ayu)
8787
--crate-search-hover-border: #e0e0e0;
8888
--source-sidebar-background-selected: #14191f;
8989
--source-sidebar-background-hover: #14191f;
90+
--table-alt-row-background-color: #191f26;
9091
}
9192

9293
h1, h2, h3, h4 {

src/librustdoc/html/static/css/themes/dark.css

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
--crate-search-hover-border: #2196f3;
8383
--source-sidebar-background-selected: #333;
8484
--source-sidebar-background-hover: #444;
85+
--table-alt-row-background-color: #2A2A2A;
8586
}
8687

8788
.content .item-info::before { color: #ccc; }

src/librustdoc/html/static/css/themes/light.css

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
--crate-search-hover-border: #717171;
8080
--source-sidebar-background-selected: #fff;
8181
--source-sidebar-background-hover: #e0e0e0;
82+
--table-alt-row-background-color: #F5F5F5;
8283
}
8384

8485
.content .item-info::before { color: #ccc; }

0 commit comments

Comments
 (0)