Skip to content

rustdoc-gui: Use new block syntax for define-function in goml scripts #106534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.13.4
0.14.1
80 changes: 41 additions & 39 deletions src/test/rustdoc-gui/anchors.goml
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,72 @@
define-function: (
"check-colors",
(theme, main_color, title_color, fqn_color, fqn_type_color, src_link_color, sidebar_link_color),
[
("goto", "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"),
block {
goto: "file://" + |DOC_PATH| + "/staged_api/struct.Foo.html"
// This is needed to ensure that the text color is computed.
("show-text", true),
show-text: true

// Setting the theme.
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
("reload"),
reload:

("assert-css", ("#toggle-all-docs", {"color": |main_color|})),
("assert-css", (".fqn a:nth-of-type(1)", {"color": |fqn_color|})),
("assert-css", (".fqn a:nth-of-type(2)", {"color": |fqn_type_color|})),
("assert-css", (
assert-css: ("#toggle-all-docs", {"color": |main_color|})
assert-css: (".fqn a:nth-of-type(1)", {"color": |fqn_color|})
assert-css: (".fqn a:nth-of-type(2)", {"color": |fqn_type_color|})
assert-css: (
".rightside .srclink",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
ALL,
)),
(
"compare-elements-css",
(".rightside .srclink", ".rightside.srclink", ["color", "text-decoration"]),
),
(
"compare-elements-css",
(".main-heading .srclink", ".rightside.srclink", ["color", "text-decoration"]),
),
)
compare-elements-css: (
".rightside .srclink",
".rightside.srclink",
["color", "text-decoration"],
)
compare-elements-css: (
".main-heading .srclink",
".rightside.srclink",
["color", "text-decoration"],
)

("move-cursor-to", ".main-heading .srclink"),
("assert-css", (
move-cursor-to: ".main-heading .srclink"
assert-css: (
".main-heading .srclink",
{"color": |src_link_color|, "text-decoration": "underline solid " + |src_link_color|},
)),
("move-cursor-to", ".impl-items .rightside .srclink"),
("assert-css", (
)
move-cursor-to: ".impl-items .rightside .srclink"
assert-css: (
".impl-items .rightside .srclink",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
)),
("move-cursor-to", ".impl-items .rightside.srclink"),
("assert-css", (
)
move-cursor-to: ".impl-items .rightside.srclink"
assert-css: (
".impl-items .rightside.srclink",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
)),
)

("goto", "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"),
goto: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
// Since we changed page, we need to set the theme again.
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
("reload"),
reload:

("assert-css", ("#top-doc-prose-title", {"color": |title_color|})),
assert-css: ("#top-doc-prose-title", {"color": |title_color|})

("assert-css", (".sidebar a", {"color": |sidebar_link_color|})),
("assert-css", ("h1.fqn a", {"color": |title_color|})),
assert-css: (".sidebar a", {"color": |sidebar_link_color|})
assert-css: ("h1.fqn a", {"color": |title_color|})

// We move the cursor over the "Implementations" title so the anchor is displayed.
("move-cursor-to", "h2#implementations"),
("assert-css", ("h2#implementations a.anchor", {"color": |main_color|})),
move-cursor-to: "h2#implementations"
assert-css: ("h2#implementations a.anchor", {"color": |main_color|})

// Same thing with the impl block title.
("move-cursor-to", "#impl-HeavilyDocumentedStruct"),
("assert-css", ("#impl-HeavilyDocumentedStruct a.anchor", {"color": |main_color|})),
move-cursor-to: "#impl-HeavilyDocumentedStruct"
assert-css: ("#impl-HeavilyDocumentedStruct a.anchor", {"color": |main_color|})

("assert-css", ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})),
],
assert-css: ("#title-for-struct-impl-item-doc", {"margin-left": "0px"})
},
)

call-function: (
Expand Down
12 changes: 6 additions & 6 deletions src/test/rustdoc-gui/code-color.goml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ show-text: true
define-function: (
"check-colors",
(theme, doc_code_color, doc_inline_code_color),
[
block {
// Set the theme.
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
("reload"),
("assert-css", (".docblock pre > code", {"color": |doc_code_color|}, ALL)),
("assert-css", (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)),
],
reload:
assert-css: (".docblock pre > code", {"color": |doc_code_color|}, ALL)
assert-css: (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)
},
)

call-function: ("check-colors", ("ayu", "rgb(230, 225, 207)", "rgb(255, 180, 84)"))
Expand Down
86 changes: 43 additions & 43 deletions src/test/rustdoc-gui/codeblock-tooltip.goml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ show-text: true
define-function: (
"check-colors",
(theme, background, color, border),
[
block {
// Setting the theme.
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"),
local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:

// compile_fail block
("assert-css", (
assert-css: (
".docblock .example-wrap.compile_fail .tooltip",
{"color": "rgba(255, 0, 0, 0.5)"},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.compile_fail",
{"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
)),
)

("move-cursor-to", ".docblock .example-wrap.compile_fail .tooltip"),
move-cursor-to: ".docblock .example-wrap.compile_fail .tooltip"

("assert-css", (
assert-css: (
".docblock .example-wrap.compile_fail .tooltip",
{"color": "rgb(255, 0, 0)"},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.compile_fail",
{"border-left": "2px solid rgb(255, 0, 0)"},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.compile_fail .tooltip::after",
{
"content": '"This example deliberately fails to compile"',
Expand All @@ -39,37 +39,37 @@ define-function: (
"color": |color|,
"border": "1px solid " + |border|,
},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.compile_fail .tooltip::before",
{
"border-width": "5px",
"border-style": "solid",
"border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)",
},
)),
)

// should_panic block
("assert-css", (
assert-css: (
".docblock .example-wrap.should_panic .tooltip",
{"color": "rgba(255, 0, 0, 0.5)"},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.should_panic",
{"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
)),
)

("move-cursor-to", ".docblock .example-wrap.should_panic .tooltip"),
move-cursor-to: ".docblock .example-wrap.should_panic .tooltip"

("assert-css", (
assert-css: (
".docblock .example-wrap.should_panic .tooltip",
{"color": "rgb(255, 0, 0)"},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.should_panic",
{"border-left": "2px solid rgb(255, 0, 0)"},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.should_panic .tooltip::after",
{
"content": '"This example panics"',
Expand All @@ -78,37 +78,37 @@ define-function: (
"color": |color|,
"border": "1px solid " + |border|,
},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.should_panic .tooltip::before",
{
"border-width": "5px",
"border-style": "solid",
"border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)",
},
)),
)

// ignore block
("assert-css", (
assert-css: (
".docblock .example-wrap.ignore .tooltip",
{"color": "rgba(255, 142, 0, 0.6)"},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.ignore",
{"border-left": "2px solid rgba(255, 142, 0, 0.6)"},
)),
)

("move-cursor-to", ".docblock .example-wrap.ignore .tooltip"),
move-cursor-to: ".docblock .example-wrap.ignore .tooltip"

("assert-css", (
assert-css: (
".docblock .example-wrap.ignore .tooltip",
{"color": "rgb(255, 142, 0)"},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.ignore",
{"border-left": "2px solid rgb(255, 142, 0)"},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.ignore .tooltip::after",
{
"content": '"This example is not tested"',
Expand All @@ -117,16 +117,16 @@ define-function: (
"color": |color|,
"border": "1px solid " + |border|,
},
)),
("assert-css", (
)
assert-css: (
".docblock .example-wrap.ignore .tooltip::before",
{
"border-width": "5px",
"border-style": "solid",
"border-color": "rgba(0, 0, 0, 0) " + |background| + " rgba(0, 0, 0, 0) rgba(0, 0, 0, 0)",
},
)),
],
)
},
)

call-function: ("check-colors", {
Expand Down
16 changes: 8 additions & 8 deletions src/test/rustdoc-gui/docblock-code-block-line-number.goml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ assert-false: "pre.example-line-numbers"
define-function: (
"check-colors",
(theme, color),
[
block {
// We now set the setting to show the line numbers on code examples.
("local-storage", {
local-storage: {
"rustdoc-theme": |theme|,
"rustdoc-use-system-theme": "false",
"rustdoc-line-numbers": "true"
}),
}
// We reload to make the line numbers appear and change theme.
("reload"),
reload:
// We wait for them to be added into the DOM by the JS...
("wait-for", "pre.example-line-numbers"),
wait-for: "pre.example-line-numbers"
// If the test didn't fail, it means that it was found!
("assert-css", (
assert-css: (
"pre.example-line-numbers",
{
"color": |color|,
Expand All @@ -32,8 +32,8 @@ define-function: (
"text-align": "right",
},
ALL,
)),
],
)
},
)
call-function: ("check-colors", {
"theme": "ayu",
Expand Down
32 changes: 16 additions & 16 deletions src/test/rustdoc-gui/docblock-table.goml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ compare-elements-css: (".impl-items .docblock table td", ".top-doc .docblock tab
define-function: (
"check-colors",
(theme, border_color, zebra_stripe_color),
[
("local-storage", {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}),
("reload"),
("assert-css", (".top-doc .docblock table tbody tr:nth-child(1)", {
block {
local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}
reload:
assert-css: (".top-doc .docblock table tbody tr:nth-child(1)", {
"background-color": "rgba(0, 0, 0, 0)",
})),
("assert-css", (".top-doc .docblock table tbody tr:nth-child(2)", {
})
assert-css: (".top-doc .docblock table tbody tr:nth-child(2)", {
"background-color": |zebra_stripe_color|,
})),
("assert-css", (".top-doc .docblock table tbody tr:nth-child(3)", {
})
assert-css: (".top-doc .docblock table tbody tr:nth-child(3)", {
"background-color": "rgba(0, 0, 0, 0)",
})),
("assert-css", (".top-doc .docblock table tbody tr:nth-child(4)", {
})
assert-css: (".top-doc .docblock table tbody tr:nth-child(4)", {
"background-color": |zebra_stripe_color|,
})),
("assert-css", (".top-doc .docblock table td", {
})
assert-css: (".top-doc .docblock table td", {
"border-style": "solid",
"border-width": "1px",
"border-color": |border_color|,
})),
("assert-css", (".top-doc .docblock table th", {
})
assert-css: (".top-doc .docblock table th", {
"border-style": "solid",
"border-width": "1px",
"border-color": |border_color|,
})),
]
})
}
)

call-function: ("check-colors", {
Expand Down
Loading