Skip to content

Commit e8d5ae4

Browse files
Update rustdoc tests for headings indent
1 parent 6aad08f commit e8d5ae4

File tree

3 files changed

+13
-79
lines changed

3 files changed

+13
-79
lines changed

src/librustdoc/html/markdown/tests.rs

+7-34
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ fn test_header() {
159159
assert_eq!(output, expect, "original: {}", input);
160160
}
161161

162-
t(
163-
"# Foo bar",
164-
"<h2 id=\"foo-bar\"><a href=\"#foo-bar\">Foo bar</a></h2>",
165-
);
162+
t("# Foo bar", "<h2 id=\"foo-bar\"><a href=\"#foo-bar\">Foo bar</a></h2>");
166163
t(
167164
"## Foo-bar_baz qux",
168165
"<h3 id=\"foo-bar_baz-qux\">\
@@ -201,36 +198,12 @@ fn test_header_ids_multiple_blocks() {
201198
assert_eq!(output, expect, "original: {}", input);
202199
}
203200

204-
t(
205-
&mut map,
206-
"# Example",
207-
"<h2 id=\"example\"><a href=\"#example\">Example</a></h2>",
208-
);
209-
t(
210-
&mut map,
211-
"# Panics",
212-
"<h2 id=\"panics\"><a href=\"#panics\">Panics</a></h2>",
213-
);
214-
t(
215-
&mut map,
216-
"# Example",
217-
"<h2 id=\"example-1\"><a href=\"#example-1\">Example</a></h2>",
218-
);
219-
t(
220-
&mut map,
221-
"# Search",
222-
"<h2 id=\"search-1\"><a href=\"#search-1\">Search</a></h2>",
223-
);
224-
t(
225-
&mut map,
226-
"# Example",
227-
"<h2 id=\"example-2\"><a href=\"#example-2\">Example</a></h2>",
228-
);
229-
t(
230-
&mut map,
231-
"# Panics",
232-
"<h2 id=\"panics-1\"><a href=\"#panics-1\">Panics</a></h2>",
233-
);
201+
t(&mut map, "# Example", "<h2 id=\"example\"><a href=\"#example\">Example</a></h2>");
202+
t(&mut map, "# Panics", "<h2 id=\"panics\"><a href=\"#panics\">Panics</a></h2>");
203+
t(&mut map, "# Example", "<h2 id=\"example-1\"><a href=\"#example-1\">Example</a></h2>");
204+
t(&mut map, "# Search", "<h2 id=\"search-1\"><a href=\"#search-1\">Search</a></h2>");
205+
t(&mut map, "# Example", "<h2 id=\"example-2\"><a href=\"#example-2\">Example</a></h2>");
206+
t(&mut map, "# Panics", "<h2 id=\"panics-1\"><a href=\"#panics-1\">Panics</a></h2>");
234207
}
235208

236209
#[test]

src/test/rustdoc-gui/anchors.goml

-42
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,4 @@ assert-css: ("h2#implementations a.anchor", {"color": "rgb(0, 0, 0)"})
3131
move-cursor-to: "#impl"
3232
assert-css: ("#impl a.anchor", {"color": "rgb(0, 0, 0)"})
3333

34-
// Now we check the positions: only the first heading of the top doc comment should
35-
// have a different position.
36-
move-cursor-to: ".top-doc .docblock .section-header:first-child"
37-
assert-css: (
38-
".top-doc .docblock .section-header:first-child > a::before",
39-
{"left": "-10px", "padding-right": "10px"},
40-
)
41-
// We also check that the heading itself has a different indent.
42-
assert-css: (".top-doc .docblock .section-header:first-child", {"margin-left": "15px"})
43-
44-
move-cursor-to: ".top-doc .docblock .section-header:not(:first-child)"
45-
assert-css: (
46-
".top-doc .docblock .section-header:not(:first-child) > a::before",
47-
{"left": "-25px", "padding-right": "10px"},
48-
)
49-
assert-css: (".top-doc .docblock .section-header:not(:first-child)", {"margin-left": "0px"})
50-
51-
// Now let's check some other docblock headings...
52-
// First the impl block docs.
53-
move-cursor-to: "#title-for-struct-impl-doc"
54-
assert-css: (
55-
"#title-for-struct-impl-doc > a::before",
56-
{"left": "-25px", "padding-right": "10px"},
57-
)
58-
assert-css: ("#title-for-struct-impl-doc", {"margin-left": "0px"})
59-
// Now a method docs.
60-
move-cursor-to: "#title-for-struct-impl-item-doc"
61-
assert-css: (
62-
"#title-for-struct-impl-item-doc > a::before",
63-
{"left": "-25px", "padding-right": "10px"},
64-
)
6534
assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})
66-
67-
// Finally, we want to ensure that if the first element of the doc block isn't a heading,
68-
// if there is a heading afterwards, it won't have the indent.
69-
goto: file://|DOC_PATH|/test_docs/enum.WhoLetTheDogOut.html
70-
71-
move-cursor-to: ".top-doc .docblock .section-header"
72-
assert-css: (
73-
".top-doc .docblock .section-header > a::before",
74-
{"left": "-25px", "padding-right": "10px"},
75-
)
76-
assert-css: (".top-doc .docblock .section-header", {"margin-left": "0px"})

src/test/rustdoc-gui/headers-color.goml

+6-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ goto: file://|DOC_PATH|/test_docs/index.html
4040
assert-css: (".small-section-header a", {"color": "rgb(197, 197, 197)"}, ALL)
4141

4242
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
43-
assert-css: (".section-header a", {"color": "rgb(57, 175, 215)"}, ALL)
43+
// We select headings (h2, h3, h...).
44+
assert-css: (".docblock > :not(p) > a", {"color": "rgb(57, 175, 215)"}, ALL)
4445

4546
// Dark theme
4647
local-storage: {
@@ -78,7 +79,8 @@ goto: file://|DOC_PATH|/test_docs/index.html
7879
assert-css: (".small-section-header a", {"color": "rgb(221, 221, 221)"}, ALL)
7980

8081
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
81-
assert-css: (".section-header a", {"color": "rgb(210, 153, 29)"}, ALL)
82+
// We select headings (h2, h3, h...).
83+
assert-css: (".docblock > :not(p) > a", {"color": "rgb(210, 153, 29)"}, ALL)
8284

8385
// Light theme
8486
local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
@@ -111,4 +113,5 @@ goto: file://|DOC_PATH|/test_docs/index.html
111113
assert-css: (".small-section-header a", {"color": "rgb(0, 0, 0)"}, ALL)
112114

113115
goto: file://|DOC_PATH|/test_docs/struct.HeavilyDocumentedStruct.html
114-
assert-css: (".section-header a", {"color": "rgb(56, 115, 173)"}, ALL)
116+
// We select headings (h2, h3, h...).
117+
assert-css: (".docblock > :not(p) > a", {"color": "rgb(56, 115, 173)"}, ALL)

0 commit comments

Comments
 (0)