Skip to content
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

rustdoc: copy code button obscures scraped example expand button #129763

Closed
willcrichton opened this issue Aug 29, 2024 · 4 comments · Fixed by #129796
Closed

rustdoc: copy code button obscures scraped example expand button #129763

willcrichton opened this issue Aug 29, 2024 · 4 comments · Fixed by #129796
Labels
A-rustdoc-scrape-examples Area: The (unstable) rustdoc scrape-examples feature described in RFC 3123 C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@willcrichton
Copy link
Contributor

Rustdoc's copy code button introduced in 9946a68 conflicts with the UI for interacting with scraped code examples. I noticed this in the wild in Bevy's documentation: https://docs.rs/bevy/0.14.1/bevy/app/struct.App.html#scraped-examples-1

In the upper right corner is a button for expanding a snipper:

Screenshot 2024-08-29 at 2 46 10 PM

But hovering over the snippet shows the copy code button, obscuring the expand button:

Screenshot 2024-08-29 at 2 46 24 PM

cc @GuillaumeGomez

@willcrichton willcrichton added the C-bug Category: This is a bug. label Aug 29, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 29, 2024
@fmease fmease added A-rustdoc-scrape-examples Area: The (unstable) rustdoc scrape-examples feature described in RFC 3123 T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. requires-nightly This issue requires a nightly compiler in some way. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 29, 2024
@GuillaumeGomez
Copy link
Member

Arf indeed. I think code unification will be needed for this feature with the other code blocks to prevent such regressions in the future. Gonna send a fix.

@GuillaumeGomez
Copy link
Member

I decided to integrate the buttons with the existing code examples. For now it looks like this:

image

@willcrichton
Copy link
Contributor Author

That looks great! Do the buttons have the same behavior where they only appear when you hover over the snippet?

@GuillaumeGomez
Copy link
Member

Yes! I'm also planning to only generate them if they don't already exist on hover like the copy button (it is only created after you first hovered the code example), it'll reduce the HTML size quite a lot. I also simplified the HTML a bit (again, smaller). I almost didn't change anything in the scraped example JS code, which is quite nice. I expected more changes to be needed. Well done!

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 3, 2024
…, r=notriddle

Unify scraped examples with other code examples

Fixes rust-lang#129763.

This first PR both fixes rust-lang#129763 but also unifies buttons display for code examples:

![image](https://github.com/user-attachments/assets/c8475945-dcc3-4c25-8d7d-1659f85301c8)

You can test it [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test.html) and [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test_many.html).

I'm planning to send a follow-up to make the buttons generated in JS directly (or I can do it in this PR directly if you prefer).

cc `@willcrichton`
r? `@notriddle`
tgross35 added a commit to tgross35/rust that referenced this issue Sep 4, 2024
…, r=notriddle

Unify scraped examples with other code examples

Fixes rust-lang#129763.

This first PR both fixes rust-lang#129763 but also unifies buttons display for code examples:

![image](https://github.com/user-attachments/assets/c8475945-dcc3-4c25-8d7d-1659f85301c8)

You can test it [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test.html) and [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test_many.html).

I'm planning to send a follow-up to make the buttons generated in JS directly (or I can do it in this PR directly if you prefer).

cc ``@willcrichton``
r? ``@notriddle``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 5, 2024
…, r=notriddle

Unify scraped examples with other code examples

Fixes rust-lang#129763.

This first PR both fixes rust-lang#129763 but also unifies buttons display for code examples:

![image](https://github.com/user-attachments/assets/c8475945-dcc3-4c25-8d7d-1659f85301c8)

You can test it [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test.html) and [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test_many.html).

I'm planning to send a follow-up to make the buttons generated in JS directly (or I can do it in this PR directly if you prefer).

cc `@willcrichton`
r? `@notriddle`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 5, 2024
…, r=notriddle

Unify scraped examples with other code examples

Fixes rust-lang#129763.

This first PR both fixes rust-lang#129763 but also unifies buttons display for code examples:

![image](https://github.com/user-attachments/assets/c8475945-dcc3-4c25-8d7d-1659f85301c8)

You can test it [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test.html) and [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test_many.html).

I'm planning to send a follow-up to make the buttons generated in JS directly (or I can do it in this PR directly if you prefer).

cc ``@willcrichton``
r? ``@notriddle``
@bors bors closed this as completed in 9be97ae Sep 5, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 5, 2024
Rollup merge of rust-lang#129796 - GuillaumeGomez:unify-code-examples, r=notriddle

Unify scraped examples with other code examples

Fixes rust-lang#129763.

This first PR both fixes rust-lang#129763 but also unifies buttons display for code examples:

![image](https://github.com/user-attachments/assets/c8475945-dcc3-4c25-8d7d-1659f85301c8)

You can test it [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test.html) and [here](https://rustdoc.crud.net/imperio/unify-code-examples/doc/scrape_examples/fn.test_many.html).

I'm planning to send a follow-up to make the buttons generated in JS directly (or I can do it in this PR directly if you prefer).

cc ```@willcrichton```
r? ```@notriddle```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-scrape-examples Area: The (unstable) rustdoc scrape-examples feature described in RFC 3123 C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants