-
Notifications
You must be signed in to change notification settings - Fork 13.2k
/
Copy pathsidebar-modnav-position.goml
63 lines (58 loc) · 3.32 KB
/
sidebar-modnav-position.goml
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
// Verifies that, when TOC is hidden, modnav is always in exactly the same spot
// This is driven by a reasonably common use case:
//
// - There are three or more items that might meet my needs.
// - I open the first one, decide it's not what I want, switch to the second one using the sidebar.
// - The second one also doesn't meet my needs, so I switch to the third.
// - The third also doesn't meet my needs, so...
//
// because the sibling module nav is in exactly the same place every time,
// it's very easy to find and switch between pages that way.
// First, in tablet-ish mode
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
set-window-size: (1280, 800)
show-text: true
set-local-storage: {"rustdoc-hide-toc": "true"}
define-function: (
"check-positions",
[url],
block {
go-to: "file://" + |DOC_PATH| + |url|
// Checking results colors.
assert-position: ("#rustdoc-modnav > section > h2", {"x": |h2_x|, "y": |h2_y|})
assert-position: (
"#rustdoc-modnav > section > ul:first-of-type > li:first-of-type",
{"x": |x|, "y": |y|}
)
},
)
// First, at test_docs root
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
store-position: ("#rustdoc-modnav > section > h2", {"x": h2_x, "y": h2_y})
store-position: ("#rustdoc-modnav > section > ul:first-of-type > li:first-of-type", {"x": x, "y": y})
call-function: ("check-positions", {"url": "/test_docs/enum.WhoLetTheDogOut.html"})
call-function: ("check-positions", {"url": "/test_docs/struct.StructWithPublicUndocumentedFields.html"})
call-function: ("check-positions", {"url": "/test_docs/codeblock_sub/index.html"})
// Now in a submodule
go-to: "file://" + |DOC_PATH| + "/test_docs/fields/struct.Struct.html"
store-position: ("#rustdoc-modnav > section > h2", {"x": h2_x, "y": h2_y})
store-position: ("#rustdoc-modnav > section > ul:first-of-type > li:first-of-type", {"x": x, "y": y})
call-function: ("check-positions", {"url": "/test_docs/fields/struct.Struct.html"})
call-function: ("check-positions", {"url": "/test_docs/fields/union.Union.html"})
call-function: ("check-positions", {"url": "/test_docs/fields/enum.Enum.html"})
// Now try similar, but in desktop-ish mode
// Unlike in tablet mode, desktop mode pulls the TOC out of the main left sidebar into its own pane,
// so modnav (which remains in the left sidebar) doesn't move regardless.
// It also has the same position as the item-decl.
set-local-storage: {"rustdoc-hide-toc": "false"}
set-window-size: (1920, 1080)
go-to: "file://" + |DOC_PATH| + "/test_docs/enum.WhoLetTheDogOut.html"
store-position: ("#rustdoc-modnav > section > h2", {"x": h2_x, "y": h2_y})
store-position: ("#rustdoc-modnav > section > ul:first-of-type > li:first-of-type", {"x": x, "y": y})
call-function: ("check-positions", {"url": "/test_docs/enum.WhoLetTheDogOut.html"})
compare-elements-position: ("#rustdoc-toc > section", ".item-decl", ["y"])
compare-elements-css: ("#rustdoc-toc > section", ".item-decl", ["border-radius"])
call-function: ("check-positions", {"url": "/test_docs/struct.StructWithPublicUndocumentedFields.html"})
compare-elements-position: ("#rustdoc-toc > section", ".item-decl", ["y"])
compare-elements-css: ("#rustdoc-toc > section", ".item-decl", ["border-radius"])
call-function: ("check-positions", {"url": "/test_docs/codeblock_sub/index.html"})