Skip to content
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
4 changes: 3 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,11 @@ nav.sub {
display: initial;
}
.anchor {
--anchor-link-shift: 0.5em;
display: none;
position: absolute;
left: -0.5em;
left: calc(var(--anchor-link-shift) * -1);
padding-right: var(--anchor-link-shift);
background: none !important;
}
.anchor.field {
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-gui/anchor-navigable.goml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
// We check that ".item-info" is bigger than its content.
move-cursor-to: ".impl"
assert-property: (".impl > a.anchor", {"offsetWidth": "8"})
assert-property: (".impl > a.anchor", {"offsetWidth": "16"})
assert-css: (".impl > a.anchor", {"left": "-8px"})
38 changes: 26 additions & 12 deletions tests/rustdoc-gui/anchors.goml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ define-function: (
assert-css: ("#toggle-all-docs", {"color": |main_color|})
assert-css: (".main-heading h1 span", {"color": |main_heading_type_color|})
assert-css: (
".rightside a.src",
{"color": |src_link_color|, "text-decoration": "none"},
ALL,
".rightside a.src",
{"color": |src_link_color|, "text-decoration": "none"},
ALL,
)
compare-elements-css: (
".rightside a.src",
Expand All @@ -31,25 +31,39 @@ define-function: (

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

// Now we ensure that the `§` anchor is "reachable" for users on trait methods.
// To ensure the anchor is not hovered, we move the cursor to another item.
move-cursor-to: "#search-button"
// By default, the anchor is not displayed.
wait-for-css: ("#method\.vroum .anchor", {"display": "none"})
// Once we move the cursor to the method, the anchor should appear.
move-cursor-to: "#method\.vroum .code-header"
assert-css-false: ("#method\.vroum .anchor", {"display": "none"})
// Now we move the cursor to the anchor to check there is no gap between the method and the
// anchor, making the anchor disappear and preventing users to click on it.
// To make it work, we need to first move it between the method and the anchor.
store-position: ("#method\.vroum .code-header", {"x": method_x, "y": method_y})
move-cursor-to: (|method_x| - 2, |method_y|)
// Anchor should still be displayed.
assert-css-false: ("#method\.vroum .anchor", {"display": "none"})

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

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

Expand Down
8 changes: 8 additions & 0 deletions tests/rustdoc-gui/src/staged_api/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#![stable(feature = "some_feature", since = "1.3.5")]
#![doc(rust_logo)]

pub trait X {
fn vroum();
}

#[stable(feature = "some_feature", since = "1.3.5")]
pub struct Foo {}

Expand All @@ -13,3 +17,7 @@ impl Foo {
#[stable(feature = "some_other_feature", since = "1.3.6")]
pub fn yo() {}
}

impl X for Foo {
fn vroum() {}
}
Loading