From e8d5ae41a118364bc9897d01fa67a3838712b7c2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 9 Feb 2022 14:44:10 +0100 Subject: [PATCH] Update rustdoc tests for headings indent --- src/librustdoc/html/markdown/tests.rs | 41 +++++------------------- src/test/rustdoc-gui/anchors.goml | 42 ------------------------- src/test/rustdoc-gui/headers-color.goml | 9 ++++-- 3 files changed, 13 insertions(+), 79 deletions(-) diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index 6b44e447b51..5c0bf0ed942 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -159,10 +159,7 @@ fn test_header() { assert_eq!(output, expect, "original: {}", input); } - t( - "# Foo bar", - "

Foo bar

", - ); + t("# Foo bar", "

Foo bar

"); t( "## Foo-bar_baz qux", "

\ @@ -201,36 +198,12 @@ fn test_header_ids_multiple_blocks() { assert_eq!(output, expect, "original: {}", input); } - t( - &mut map, - "# Example", - "

Example

", - ); - t( - &mut map, - "# Panics", - "

Panics

", - ); - t( - &mut map, - "# Example", - "

Example

", - ); - t( - &mut map, - "# Search", - "

Search

", - ); - t( - &mut map, - "# Example", - "

Example

", - ); - t( - &mut map, - "# Panics", - "

Panics

", - ); + t(&mut map, "# Example", "

Example

"); + t(&mut map, "# Panics", "

Panics

"); + t(&mut map, "# Example", "

Example

"); + t(&mut map, "# Search", "

Search

"); + t(&mut map, "# Example", "

Example

"); + t(&mut map, "# Panics", "

Panics

"); } #[test] diff --git a/src/test/rustdoc-gui/anchors.goml b/src/test/rustdoc-gui/anchors.goml index 26e4503a5d0..ddfb23a4f86 100644 --- a/src/test/rustdoc-gui/anchors.goml +++ b/src/test/rustdoc-gui/anchors.goml @@ -31,46 +31,4 @@ assert-css: ("h2#implementations a.anchor", {"color": "rgb(0, 0, 0)"}) move-cursor-to: "#impl" assert-css: ("#impl a.anchor", {"color": "rgb(0, 0, 0)"}) -// Now we check the positions: only the first heading of the top doc comment should -// have a different position. -move-cursor-to: ".top-doc .docblock .section-header:first-child" -assert-css: ( - ".top-doc .docblock .section-header:first-child > a::before", - {"left": "-10px", "padding-right": "10px"}, -) -// We also check that the heading itself has a different indent. -assert-css: (".top-doc .docblock .section-header:first-child", {"margin-left": "15px"}) - -move-cursor-to: ".top-doc .docblock .section-header:not(:first-child)" -assert-css: ( - ".top-doc .docblock .section-header:not(:first-child) > a::before", - {"left": "-25px", "padding-right": "10px"}, -) -assert-css: (".top-doc .docblock .section-header:not(:first-child)", {"margin-left": "0px"}) - -// Now let's check some other docblock headings... -// First the impl block docs. -move-cursor-to: "#title-for-struct-impl-doc" -assert-css: ( - "#title-for-struct-impl-doc > a::before", - {"left": "-25px", "padding-right": "10px"}, -) -assert-css: ("#title-for-struct-impl-doc", {"margin-left": "0px"}) -// Now a method docs. -move-cursor-to: "#title-for-struct-impl-item-doc" -assert-css: ( - "#title-for-struct-impl-item-doc > a::before", - {"left": "-25px", "padding-right": "10px"}, -) assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"}) - -// Finally, we want to ensure that if the first element of the doc block isn't a heading, -// if there is a heading afterwards, it won't have the indent. -goto: file://|DOC_PATH|/test_docs/enum.WhoLetTheDogOut.html - -move-cursor-to: ".top-doc .docblock .section-header" -assert-css: ( - ".top-doc .docblock .section-header > a::before", - {"left": "-25px", "padding-right": "10px"}, -) -assert-css: (".top-doc .docblock .section-header", {"margin-left": "0px"}) diff --git a/src/test/rustdoc-gui/headers-color.goml b/src/test/rustdoc-gui/headers-color.goml index d58ca13a629..cf9caa2d586 100644 --- a/src/test/rustdoc-gui/headers-color.goml +++ b/src/test/rustdoc-gui/headers-color.goml @@ -40,7 +40,8 @@ goto: file://|DOC_PATH|/test_docs/index.html assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL) goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -assert-css: (".section-header a", {"color": "rgb(57, 175, 215)"}, ALL) +// We select headings (h2, h3, h...). +assert-css: (".docblock > :not(p) > a", {"color": "rgb(57, 175, 215)"}, ALL) // Dark theme local-storage: { @@ -78,7 +79,8 @@ goto: file://|DOC_PATH|/test_docs/index.html assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL) goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -assert-css: (".section-header a", {"color": "rgb(210, 153, 29)"}, ALL) +// We select headings (h2, h3, h...). +assert-css: (".docblock > :not(p) > a", {"color": "rgb(210, 153, 29)"}, ALL) // Light theme local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"} @@ -111,4 +113,5 @@ goto: file://|DOC_PATH|/test_docs/index.html assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL) goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html -assert-css: (".section-header a", {"color": "rgb(56, 115, 173)"}, ALL) +// We select headings (h2, h3, h...). +assert-css: (".docblock > :not(p) > a", {"color": "rgb(56, 115, 173)"}, ALL)