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);
|
assert_eq!(output, expect, "original: {}", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
t(
|
t("# Foo bar", "<h2 id=\"foo-bar\"><a href=\"#foo-bar\">Foo bar</a></h2>");
|
||||||
"# Foo bar",
|
|
||||||
"<h2 id=\"foo-bar\"><a href=\"#foo-bar\">Foo bar</a></h2>",
|
|
||||||
);
|
|
||||||
t(
|
t(
|
||||||
"## Foo-bar_baz qux",
|
"## Foo-bar_baz qux",
|
||||||
"<h3 id=\"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);
|
assert_eq!(output, expect, "original: {}", input);
|
||||||
}
|
}
|
||||||
|
|
||||||
t(
|
t(&mut map, "# Example", "<h2 id=\"example\"><a href=\"#example\">Example</a></h2>");
|
||||||
&mut map,
|
t(&mut map, "# Panics", "<h2 id=\"panics\"><a href=\"#panics\">Panics</a></h2>");
|
||||||
"# Example",
|
t(&mut map, "# Example", "<h2 id=\"example-1\"><a href=\"#example-1\">Example</a></h2>");
|
||||||
"<h2 id=\"example\"><a href=\"#example\">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(
|
t(&mut map, "# Panics", "<h2 id=\"panics-1\"><a href=\"#panics-1\">Panics</a></h2>");
|
||||||
&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]
|
#[test]
|
||||||
|
@ -31,46 +31,4 @@ assert-css: ("h2#implementations a.anchor", {"color": "rgb(0, 0, 0)"})
|
|||||||
move-cursor-to: "#impl"
|
move-cursor-to: "#impl"
|
||||||
assert-css: ("#impl a.anchor", {"color": "rgb(0, 0, 0)"})
|
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"})
|
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)
|
assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL)
|
||||||
|
|
||||||
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
|
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
|
// Dark theme
|
||||||
local-storage: {
|
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)
|
assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL)
|
||||||
|
|
||||||
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
|
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
|
// Light theme
|
||||||
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
|
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)
|
assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL)
|
||||||
|
|
||||||
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
|
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