Update rustdoc tests for headings indent
This commit is contained in:
parent
6aad08f13f
commit
e8d5ae41a1
@ -159,10 +159,7 @@ fn test_header() {
|
||||
assert_eq!(output, expect, "original: {}", input);
|
||||
}
|
||||
|
||||
t(
|
||||
"# Foo bar",
|
||||
"<h2 id=\"foo-bar\"><a href=\"#foo-bar\">Foo bar</a></h2>",
|
||||
);
|
||||
t("# Foo bar", "<h2 id=\"foo-bar\"><a href=\"#foo-bar\">Foo bar</a></h2>");
|
||||
t(
|
||||
"## Foo-bar_baz qux",
|
||||
"<h3 id=\"foo-bar_baz-qux\">\
|
||||
@ -201,36 +198,12 @@ fn test_header_ids_multiple_blocks() {
|
||||
assert_eq!(output, expect, "original: {}", input);
|
||||
}
|
||||
|
||||
t(
|
||||
&mut map,
|
||||
"# Example",
|
||||
"<h2 id=\"example\"><a href=\"#example\">Example</a></h2>",
|
||||
);
|
||||
t(
|
||||
&mut map,
|
||||
"# Panics",
|
||||
"<h2 id=\"panics\"><a href=\"#panics\">Panics</a></h2>",
|
||||
);
|
||||
t(
|
||||
&mut map,
|
||||
"# Example",
|
||||
"<h2 id=\"example-1\"><a href=\"#example-1\">Example</a></h2>",
|
||||
);
|
||||
t(
|
||||
&mut map,
|
||||
"# Search",
|
||||
"<h2 id=\"search-1\"><a href=\"#search-1\">Search</a></h2>",
|
||||
);
|
||||
t(
|
||||
&mut map,
|
||||
"# Example",
|
||||
"<h2 id=\"example-2\"><a href=\"#example-2\">Example</a></h2>",
|
||||
);
|
||||
t(
|
||||
&mut map,
|
||||
"# Panics",
|
||||
"<h2 id=\"panics-1\"><a href=\"#panics-1\">Panics</a></h2>",
|
||||
);
|
||||
t(&mut map, "# Example", "<h2 id=\"example\"><a href=\"#example\">Example</a></h2>");
|
||||
t(&mut map, "# Panics", "<h2 id=\"panics\"><a href=\"#panics\">Panics</a></h2>");
|
||||
t(&mut map, "# Example", "<h2 id=\"example-1\"><a href=\"#example-1\">Example</a></h2>");
|
||||
t(&mut map, "# Search", "<h2 id=\"search-1\"><a href=\"#search-1\">Search</a></h2>");
|
||||
t(&mut map, "# Example", "<h2 id=\"example-2\"><a href=\"#example-2\">Example</a></h2>");
|
||||
t(&mut map, "# Panics", "<h2 id=\"panics-1\"><a href=\"#panics-1\">Panics</a></h2>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -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"})
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user