-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[rustdoc] Add copy code feature #125779
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
[rustdoc] Add copy code feature #125779
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9946a68
Add copy code button
GuillaumeGomez ddaa90f
Add rustdoc GUI test for new copy code feature
GuillaumeGomez 578810b
Make "copy code" button the same size as the "copy path" button
GuillaumeGomez 26d7251
Unify UI between code block buttons and top buttons
GuillaumeGomez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Checks that the "copy code" button is not triggering JS error and its display | ||
// isn't broken. | ||
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" | ||
|
||
define-function: ( | ||
"check-copy-button", | ||
[], | ||
block { | ||
// First we ensure that there are no "copy code" currently existing. | ||
assert-count: (".example-wrap .copy-button", 0) | ||
move-cursor-to: ".example-wrap" | ||
assert-count: (".example-wrap .copy-button", 1) | ||
// We now ensure it's only displayed when the example is hovered. | ||
assert-css: (".example-wrap .copy-button", { "visibility": "visible" }) | ||
move-cursor-to: ".search-input" | ||
assert-css: (".example-wrap .copy-button", { "visibility": "hidden" }) | ||
// Checking that the copy button has the same size as the "copy path" button. | ||
compare-elements-size: ( | ||
"#copy-path", | ||
".example-wrap:nth-of-type(1) .copy-button", | ||
["height", "width"], | ||
) | ||
}, | ||
) | ||
|
||
call-function: ("check-copy-button", {}) | ||
// Checking that the run button and the copy button have the same height. | ||
compare-elements-size: ( | ||
".example-wrap:nth-of-type(1) .test-arrow", | ||
".example-wrap:nth-of-type(1) .copy-button", | ||
["height"], | ||
) | ||
// ... and the same y position. | ||
compare-elements-position: ( | ||
".example-wrap:nth-of-type(1) .test-arrow", | ||
".example-wrap:nth-of-type(1) .copy-button", | ||
["y"], | ||
) | ||
store-size: (".example-wrap:nth-of-type(1) .copy-button", { | ||
"height": copy_height, | ||
"width": copy_width, | ||
}) | ||
assert: |copy_height| > 0 && |copy_width| > 0 | ||
|
||
// Checking same things for the copy button when there is no run button. | ||
go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html" | ||
call-function: ("check-copy-button", {}) | ||
// Ensure there is no run button. | ||
assert-count: (".example-wrap .test-arrow", 0) | ||
// Check it's the same size without a run button. | ||
assert-size: (".example-wrap:nth-of-type(1) .copy-button", { | ||
"height": |copy_height|, | ||
"width": |copy_width|, | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.