summaryrefslogtreecommitdiffstats
path: root/src/test/rustdoc-gui/headings.goml
blob: 85e17ca9551a2af896074ffc1f5a13dd4b4162e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
// This test checks 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. 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
// 22px  1.375rem
// 20px  1.25rem
// 18px  1.125em
// 16px  1rem
// 14px  0.875rem
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"

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

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

assert-css: ("h2#fields", {"font-size": "22px"})
assert-css: ("h2#fields", {"border-bottom-width": "1px"})
assert-css: ("h3#title-for-field", {"font-size": "20px"})
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": "22px"})
assert-css: ("h2#implementations", {"border-bottom-width": "1px"})

assert-css: ("#impl-HeavilyDocumentedStruct > h3.code-header", {"font-size": "18px"})
assert-css: ("#impl-HeavilyDocumentedStruct > 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": "14px"})
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": "14px"})
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": "14px"})

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

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

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

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

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

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

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

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

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

assert-css: ("#impl-HeavilyDocumentedEnum > h3.code-header", {"font-size": "18px"})
assert-css: ("#impl-HeavilyDocumentedEnum > 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": "14px"})
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": "14px"})
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": "14px"})
assert-css: ("h6#sub-sub-heading-for-enum-impl-item-doc", {"border-bottom-width": "0px"})

assert-text: ("//ul[@class='block mod']/preceding-sibling::h3", "Modules")
assert-css: ("//ul[@class='block mod']/preceding-sibling::h3", {"border-bottom-width": "0px"}, ALL)

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

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

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

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

assert-css: ("h3#title-for-union-variant", {"font-size": "20px"})
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": "22px"})
assert-css: ("h2#implementations", {"border-bottom-width": "1px"})

assert-css: ("#impl-HeavilyDocumentedUnion > h3.code-header", {"font-size": "18px"})
assert-css: ("#impl-HeavilyDocumentedUnion > 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": "14px"})
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: ("h2#top-doc-prose-title", {"font-size": "22px"})
assert-css: ("h2#top-doc-prose-title", {"border-bottom-width": "1px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"font-size": "20px"})
assert-css: ("h3#top-doc-prose-sub-heading", {"border-bottom-width": "1px"})

// Needed to check colors
show-text: true
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"

define-function: (
    "check-colors",
    (theme, heading_color, small_heading_color, heading_border_color),
    [
        ("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
        ("reload"),
        ("assert-css", (
            ".top-doc .docblock h2",
            {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|},
        )),
        ("assert-css", (
            ".top-doc .docblock h3",
            {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|},
        )),
        ("assert-css", (
            ".top-doc .docblock h4",
            {"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|},
        )),
        ("assert-css", (
            ".top-doc .docblock h5",
            {"color": |small_heading_color|, "border-bottom-width": "0px"},
        )),
        ("assert-css", (
            "#implementations-list .docblock h4",
            {"color": |heading_color|, "border-bottom-width": "0px"},
        )),
        ("assert-css", (
            "#implementations-list .docblock h5",
            {"color": |small_heading_color|, "border-bottom-width": "0px"},
        )),
        ("assert-css", (
            "#implementations-list .docblock h6",
            {"color": |small_heading_color|, "border-bottom-width": "0px"},
        )),
    ],
)
call-function: (
    "check-colors",
    {
        "theme": "ayu",
        "heading_color": "rgb(255, 255, 255)",
        "small_heading_color": "rgb(197, 197, 197)",
        "heading_border_color": "rgb(92, 103, 115)",
    },
)
call-function: (
    "check-colors",
    {
        "theme": "dark",
        "heading_color": "rgb(221, 221, 221)",
        "small_heading_color": "rgb(221, 221, 221)",
        "heading_border_color": "rgb(210, 210, 210)",
    },
)
call-function: (
    "check-colors",
    {
        "theme": "light",
        "heading_color": "rgb(0, 0, 0)",
        "small_heading_color": "rgb(0, 0, 0)",
        "heading_border_color": "rgb(221, 221, 221)",
    },
)

define-function: (
    "check-since-color",
    (theme),
    [
        ("local-storage", {"rustdoc-theme": |theme|}),
        ("reload"),
        ("assert-css", (".since", {"color": "rgb(128, 128, 128)"}, ALL)),
    ],
)

goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"
call-function: ("check-since-color", ("ayu"))
call-function: ("check-since-color", ("dark"))
call-function: ("check-since-color", ("light"))