Skip to content

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

Closed

Description

@willcrichton

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

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 29, 2024
  2. added
    A-rustdoc-scrape-examplesArea: The (unstable) rustdoc scrape-examples feature described in RFC 3123
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 29, 2024
  3. GuillaumeGomez commented on Aug 30, 2024

    @GuillaumeGomez
    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.

  4. GuillaumeGomez commented on Aug 30, 2024

    @GuillaumeGomez
    Member

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

    image

  5. willcrichton commented on Aug 30, 2024

    @willcrichton
    ContributorAuthor

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

  6. GuillaumeGomez commented on Aug 30, 2024

    @GuillaumeGomez
    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!

  7. added a commit that references this issue on Sep 3, 2024
    eaf2ac2
  8. added a commit that references this issue on Sep 4, 2024
    784cbd7
  9. added 3 commits that reference this issue on Sep 5, 2024
    a6fe092
    3f99c12
    9be97ae
  10. added a commit that references this issue on Sep 5, 2024
    8f4c69a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-scrape-examplesArea: The (unstable) rustdoc scrape-examples feature described in RFC 3123C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions