File: headings-anchor.goml

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (32 lines) | stat: -rw-r--r-- 1,512 bytes parent folder | download | duplicates (3)
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
// Test to ensure that the headings anchor behave as expected.
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
show-text: true

define-function: (
    "check-heading-anchor",
    [heading_id],
    block {
        // The anchor should not be displayed by default.
        assert-css: ("#" + |heading_id| + " .doc-anchor", { "display": "none" })
        // We ensure that hovering the heading makes the anchor visible.
        move-cursor-to: "#" + |heading_id|
        assert-css: ("#" + |heading_id| + ":hover .doc-anchor", { "display": "block" })
        // We then ensure that moving from the heading to the anchor doesn't make the anchor
        // disappear.
        move-cursor-to: "#" + |heading_id| + " .doc-anchor"
        assert-css: ("#" + |heading_id| + " .doc-anchor:hover", {
            "display": "block",
            // We also ensure that there is no underline decoration.
            "text-decoration-line": "none",
        })
    }
)

move-cursor-to: "#top-doc-prose-title"
// If the top documentation block first element is a heading, we should never display its anchor
// to prevent it from overlapping with the `[-]` element.
assert-css: ("#top-doc-prose-title:hover .doc-anchor", { "display": "none" })

call-function: ("check-heading-anchor", {"heading_id": "top-doc-prose-sub-heading"})
call-function: ("check-heading-anchor", {"heading_id": "top-doc-prose-sub-sub-heading"})
call-function: ("check-heading-anchor", {"heading_id": "you-know-the-drill"})