Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove underlines from non-top docblocks. #90156

Merged
merged 1 commit into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ h1, h2, h3, h4 {
margin: 20px 0 15px 0;
padding-bottom: 6px;
}
h5, h6 {
.docblock h3, .docblock h4, h5, h6 {
margin: 15px 0 5px 0;
}
h1.fqn {
Expand All @@ -149,7 +149,14 @@ h1.fqn {
h1.fqn > .in-band > a:hover {
text-decoration: underline;
}
h2, h3, h4 {
/* The only headings that get underlines are:
Markdown-generated headings within the top-doc
Rustdoc-generated h2 section headings (e.g. "Implementations", "Required Methods", etc)
Underlines elsewhere in the documentation break up visual flow and tend to invert
section hierarchies. */
h2,
.top-doc h3,
.top-doc h4 {
jsha marked this conversation as resolved.
Show resolved Hide resolved
border-bottom: 1px solid;
}
h3.code-header {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// This test check that headers (a) have the correct heading level, and (b) are the right size.
// This test check that headers (a) have the correct heading level, (b) are the right size,
// and (c) have the correct underlining (or absence of underlining).
// The sizes may change as design changes, but try to make sure a lower header is never bigger than
// its parent headers.
// its parent headers. Also make sure lower headers don't have underlines when their parents lack
// an underline.
// Most of these sizes are set in CSS in `em` units, so here's a conversion chart based on our
// default 16px font size:
// 24px 1.5em
Expand All @@ -13,87 +15,139 @@
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html

assert-css: ("h1.fqn", {"font-size": "24px"})
assert-css: ("h1.fqn", {"border-bottom-width": "1px"})

assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"font-size": "17.6px"})
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"border-bottom-width": "1px"})

assert-css: ("h2#fields", {"font-size": "22.4px"})
assert-css: ("h2#fields", {"border-bottom-width": "1px"})
assert-css: ("h3#title-for-field", {"font-size": "20.8px"})
assert-css: ("h3#title-for-field", {"border-bottom-width": "0px"})
assert-css: ("h4#sub-heading-for-field", {"font-size": "16px"})
assert-css: ("h4#sub-heading-for-field", {"border-bottom-width": "0px"})

assert-css: ("h2#implementations", {"font-size": "22.4px"})
assert-css: ("h2#implementations", {"border-bottom-width": "1px"})

assert-css: ("#impl > h3.code-header", {"font-size": "17.6px"})
assert-css: ("#impl > h3.code-header", {"border-bottom-width": "0px"})
assert-css: ("#method\.do_nothing > h4.code-header", {"font-size": "16px"})
assert-css: ("#method\.do_nothing > h4.code-header", {"border-bottom-width": "0px"})

assert-css: ("h4#title-for-struct-impl-doc", {"font-size": "16px"})
assert-css: ("h4#title-for-struct-impl-doc", {"border-bottom-width": "0px"})
assert-css: ("h5#sub-heading-for-struct-impl-doc", {"font-size": "16px"})
assert-css: ("h5#sub-heading-for-struct-impl-doc", {"border-bottom-width": "0px"})
assert-css: ("h6#sub-sub-heading-for-struct-impl-doc", {"font-size": "15.2px"})
assert-css: ("h6#sub-sub-heading-for-struct-impl-doc", {"border-bottom-width": "0px"})

assert-css: ("h5#title-for-struct-impl-item-doc", {"font-size": "16px"})
assert-css: ("h5#title-for-struct-impl-item-doc", {"border-bottom-width": "0px"})
assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"font-size": "15.2px"})
assert-css: ("h6#sub-heading-for-struct-impl-item-doc", {"border-bottom-width": "0px"})
assert-css: ("h6#sub-sub-heading-for-struct-impl-item-doc", {"font-size": "15.2px"})

goto: file://|DOC_PATH|/test_docs/enum.HeavilyDocumentedEnum.html

assert-css: ("h1.fqn", {"font-size": "24px"})
assert-css: ("h1.fqn", {"border-bottom-width": "1px"})

assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"font-size": "17.6px"})
assert-css: ("h4#top-doc-prose-sub-sub-heading", {"border-bottom-width": "1px"})

assert-css: ("h2#variants", {"font-size": "22.4px"})
assert-css: ("h2#variants", {"border-bottom-width": "1px"})

assert-css: ("h3#none-prose-title", {"font-size": "20.8px"})
assert-css: ("h3#none-prose-title", {"border-bottom-width": "0px"})
assert-css: ("h4#none-prose-sub-heading", {"font-size": "16px"})
assert-css: ("h4#none-prose-sub-heading", {"border-bottom-width": "0px"})

assert-css: ("h3#wrapped-prose-title", {"font-size": "20.8px"})
assert-css: ("h3#wrapped-prose-title", {"border-bottom-width": "0px"})
assert-css: ("h4#wrapped-prose-sub-heading", {"font-size": "16px"})
assert-css: ("h4#wrapped-prose-sub-heading", {"border-bottom-width": "0px"})

assert-css: ("h4#wrapped0-prose-title", {"font-size": "16px"})
assert-css: ("h4#wrapped0-prose-title", {"border-bottom-width": "0px"})
assert-css: ("h5#wrapped0-prose-sub-heading", {"font-size": "16px"})
assert-css: ("h5#wrapped0-prose-sub-heading", {"border-bottom-width": "0px"})

assert-css: ("h4#structy-prose-title", {"font-size": "16px"})
assert-css: ("h4#structy-prose-title", {"border-bottom-width": "0px"})
assert-css: ("h5#structy-prose-sub-heading", {"font-size": "16px"})
assert-css: ("h5#structy-prose-sub-heading", {"border-bottom-width": "0px"})

assert-css: ("h2#implementations", {"font-size": "22.4px"})
assert-css: ("h2#implementations", {"border-bottom-width": "1px"})

assert-css: ("#impl > h3.code-header", {"font-size": "17.6px"})
assert-css: ("#impl > h3.code-header", {"border-bottom-width": "0px"})
assert-css: ("#method\.do_nothing > h4.code-header", {"font-size": "16px"})
assert-css: ("#method\.do_nothing > h4.code-header", {"border-bottom-width": "0px"})

assert-css: ("h4#title-for-enum-impl-doc", {"font-size": "16px"})
assert-css: ("h4#title-for-enum-impl-doc", {"border-bottom-width": "0px"})
assert-css: ("h5#sub-heading-for-enum-impl-doc", {"font-size": "16px"})
assert-css: ("h5#sub-heading-for-enum-impl-doc", {"border-bottom-width": "0px"})
assert-css: ("h6#sub-sub-heading-for-enum-impl-doc", {"font-size": "15.2px"})
assert-css: ("h6#sub-sub-heading-for-enum-impl-doc", {"border-bottom-width": "0px"})

assert-css: ("h5#title-for-enum-impl-item-doc", {"font-size": "16px"})
assert-css: ("h5#title-for-enum-impl-item-doc", {"border-bottom-width": "0px"})
assert-css: ("h6#sub-heading-for-enum-impl-item-doc", {"font-size": "15.2px"})
assert-css: ("h6#sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0px"})
assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"font-size": "15.2px"})
assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0px"})

goto: file://|DOC_PATH|/test_docs/union.HeavilyDocumentedUnion.html

assert-css: ("h1.fqn", {"font-size": "24px"})
assert-css: ("h1.fqn", {"border-bottom-width": "1px"})

assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})

assert-css: ("h2#fields", {"font-size": "22.4px"})
assert-css: ("h2#fields", {"border-bottom-width": "1px"})

assert-css: ("h3#title-for-union-variant", {"font-size": "20.8px"})
assert-css: ("h3#title-for-union-variant", {"border-bottom-width": "0px"})
assert-css: ("h4#sub-heading-for-union-variant", {"font-size": "16px"})
assert-css: ("h4#sub-heading-for-union-variant", {"border-bottom-width": "0px"})

assert-css: ("h2#implementations", {"font-size": "22.4px"})
assert-css: ("h2#implementations", {"border-bottom-width": "1px"})

assert-css: ("#impl > h3.code-header", {"font-size": "17.6px"})
assert-css: ("#impl > h3.code-header", {"border-bottom-width": "0px"})
assert-css: ("h4#title-for-union-impl-doc", {"font-size": "16px"})
assert-css: ("h4#title-for-union-impl-doc", {"border-bottom-width": "0px"})
assert-css: ("h5#sub-heading-for-union-impl-doc", {"font-size": "16px"})
assert-css: ("h5#sub-heading-for-union-impl-doc", {"border-bottom-width": "0px"})

assert-css: ("h5#title-for-union-impl-item-doc", {"font-size": "16px"})
assert-css: ("h5#title-for-union-impl-item-doc", {"border-bottom-width": "0px"})
assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"font-size": "15.2px"})
assert-css: ("h6#sub-heading-for-union-impl-item-doc", {"border-bottom-width": "0px"})

goto: file://|DOC_PATH|/test_docs/macro.heavily_documented_macro.html

assert-css: ("h1.fqn", {"font-size": "24px"})
assert-css: ("h1.fqn", {"border-bottom-width": "1px"})

assert-css: ("h2#top-doc-prose-title", {"font-size": "20.8px"})
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "18.4px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})