Commit Graph

256 Commits

Author SHA1 Message Date
Guillaume Gomez
c6e3385d95
Rollup merge of #128394 - GuillaumeGomez:run-button, r=t-rustdoc
Unify run button display with "copy code" button and with mdbook buttons

Follow-up of https://github.com/rust-lang/rust/pull/128339.

It looks like this (coherency++, yeay!):

![Screenshot from 2024-07-30 15-16-31](https://github.com/user-attachments/assets/5e262e5b-f338-4085-94ca-e223033a43db)

Can be tested [here](https://rustdoc.crud.net/imperio/run-button/foo/struct.Bar.html).

r? `@notriddle`
2024-08-12 17:09:15 +02:00
Michael Howell
3a183256ad rustdoc-search: account for numeric disambiguators on impls
Fixes #128676
2024-08-06 07:36:12 -07:00
Guillaume Gomez
59cb15946d Prevent clicking on a link or on a button to toggle the code example buttons visibility 2024-08-05 11:05:40 +02:00
Guillaume Gomez
be71bd9cec Update GUI tests for code example buttons 2024-08-05 11:04:51 +02:00
Matthias Krüger
c2b085b4d4
Rollup merge of #128339 - GuillaumeGomez:click-code-example, r=notriddle
[rustdoc] Make the buttons remain when code example is clicked

Follow-up of https://github.com/rust-lang/rust/pull/125779.

One current issue we have with "run" button and the newly added copy code button is that if you're on mobile devices, you can't use them. I took a look at how `mdbook` is handling it and when you click on a code example, they show the buttons. I think it's a really good idea as if you want to copy the code on your mobile device, you will click on it, showing the buttons.

Feature can be tested [here](https://rustdoc.crud.net/imperio/click-code-example/foo/struct.Bar.html).

r? `@notriddle`
2024-07-30 04:31:55 +02:00
Guillaume Gomez
99906dc89c Add rustdoc GUI test to check click on code examples 2024-07-29 21:14:36 +02:00
Michael Howell
3bf8bcfbe0 rustdoc: properly handle path wrapping 2024-07-29 10:31:02 -07:00
Michael Howell
0d0e18e7f6 rustdoc: use <wbr>-tolerant function to check text contents 2024-07-29 08:46:11 -07:00
Guillaume Gomez
a8cc24a1ab
Rollup merge of #125779 - GuillaumeGomez:copy-code, r=rustdoc-team
[rustdoc] Add copy code feature

This PR adds a "copy code" to code blocks. Since this is a JS only feature, the HTML is generated with JS when the user hovers the code block to prevent generating DOM unless needed.

Two things to note:
 1. I voluntarily kept the current behaviour of the run button (only when hovering a code block with a mouse) so it doesn't do anything on mobile. I plan to send a follow-up where the buttons would "expandable" or something. Still need to think which approach would be the best.
 2. I used a picture and not text like the run button to remain consistent with the "copy path" button. I'd also prefer for the run button to use a picture (like what is used in mdbook) but again, that's something to be discussed later on.

The rendering looks like this:

![Screenshot from 2024-06-03 21-29-48](https://github.com/rust-lang/rust/assets/3050060/a0b18f9c-b3dd-4a65-89a7-5a7a303b5c2b)
![Screenshot from 2024-06-03 21-30-20](https://github.com/rust-lang/rust/assets/3050060/b3b084ff-2716-4160-820b-d4774681a961)

It can be tested [here](https://guillaume-gomez.fr/rustdoc/bar/struct.Bar.html) (without the run button) and [here](https://guillaume-gomez.fr/rustdoc/foo/struct.Bar.html) (with the run button).

Fixes #86851.

r? ``@notriddle``
2024-07-28 20:07:44 +02:00
Guillaume Gomez
015f5d6f76 Add rustdoc GUI test to check title with and without search 2024-07-27 12:12:16 +02:00
Guillaume Gomez
7de26684e8 Add regression test for items list size (#128023) 2024-07-22 11:33:03 +02:00
Jubilee
5bd7525856
Rollup merge of #128014 - GuillaumeGomez:stab-in-doc-blocks, r=notriddle
Fix stab display in doc blocks

Went across this bug randomly:

![Screenshot from 2024-07-20 22-09-49](https://github.com/user-attachments/assets/89fdf427-b00e-4fcb-9d57-078bcb1bacd9)

With the fixed CSS:

![Screenshot from 2024-07-20 22-10-14](https://github.com/user-attachments/assets/eda9a1a6-6a12-408f-bd3a-25bb3397d163)

r? ```@notriddle```
2024-07-21 17:44:28 -07:00
Guillaume Gomez
84db684f49 Update source-code-page-code-scroll.goml GUI test 2024-07-21 12:47:34 +02:00
Guillaume Gomez
e4d701b1d3 Add regression test for stab display in doc blocks 2024-07-21 11:52:24 +02:00
Guillaume Gomez
eec3c3db88 Add GUI test for trait bounds display 2024-07-19 21:31:30 +02:00
Guillaume Gomez
590c01a5c5 Reduce width to ensure that the name is wider and thus still triggering the scroll 2024-07-19 21:31:30 +02:00
Matthias Krüger
1c665738de
Rollup merge of #127932 - notriddle:notriddle/current, r=GuillaumeGomez
rustdoc: fix `current` class on sidebar modnav

| Before | After |
| -- | -- |
| ![image](https://github.com/user-attachments/assets/35866be8-5a58-41eb-9169-b2bb403fe7cd) | ![image](https://github.com/user-attachments/assets/89b087ea-82bf-49f5-9c87-20162880eb32)
2024-07-19 10:48:06 +02:00
Michael Howell
2e1e627430 rustdoc: fix current class on sidebar modnav 2024-07-18 12:06:21 -07:00
Guillaume Gomez
c820a2392c Add test for size of items in the items list 2024-07-18 20:48:20 +02:00
Guillaume Gomez
26d72512e0 Unify UI between code block buttons and top buttons 2024-07-18 14:16:29 +02:00
Guillaume Gomez
578810b4d2 Make "copy code" button the same size as the "copy path" button 2024-07-18 14:16:29 +02:00
Guillaume Gomez
ddaa90fc56 Add rustdoc GUI test for new copy code feature 2024-07-18 14:16:29 +02:00
Michael Howell
55149061ea rustdoc: add test cases for mile wide bar 2024-07-16 13:29:35 -07:00
Michael Howell
3924493a10 rustdoc: make sidebar highlight cover whole click target 2024-07-15 17:44:05 -07:00
Michael Howell
5fc30b857c rustdoc: click target for sidebar items flush left 2024-07-01 18:03:58 -07:00
Guillaume Gomez
c8bbeef12f Don't call switch-theme function 2024-06-29 11:56:06 +02:00
Guillaume Gomez
b1d1e66389 Add back help-page.goml rustdoc GUI test 2024-06-29 11:56:06 +02:00
Guillaume Gomez
315be7d483 Update browser-ui-test version to 0.18.0 2024-06-27 00:04:23 +02:00
Guillaume Gomez
9e466d3361 Remove failing GUI test to stop blocking CI until it is fixed 2024-06-14 00:49:05 +02:00
Matthias Krüger
7af9ad1465
Rollup merge of #124738 - notriddle:notriddle/search-form-js, r=GuillaumeGomez
rustdoc: dedup search form HTML

This change constructs the search form HTML using JavaScript, instead of plain HTML. It uses a custom element because

- the [parser]'s insert algorithm runs the connected callback synchronously, so we won't get layout jank
- it requires very little HTML, so it's a real win in size

[parser]: https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token

This shrinks the standard library by about 60MiB, by my test.

There should be no visible changes. Just use less disk space.
2024-05-07 18:12:54 +02:00
Guillaume Gomez
e460901b13 Add GUI regression test for setting's cog color 2024-05-05 20:07:12 +02:00
Guillaume Gomez
0cbebd07ee Fix bad color for setting cog in ayu theme 2024-05-05 20:07:12 +02:00
Michael Howell
eeb59f16a5 rustdoc: dedup search form HTML
This change constructs the search form HTML using JavaScript, instead of plain HTML. It uses a custom element because

- the [parser]'s insert algorithm runs the connected callback synchronously, so we won't get layout jank
- it requires very little HTML, so it's a real win in size

[parser]: https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token

This shrinks the standard library by about 60MiB, by my test.
2024-05-05 08:15:08 -07:00
Matthias Krüger
e9b0c91cdd
Rollup merge of #124197 - GuillaumeGomez:move-duplicated-code, r=notriddle
Move duplicated code in functions in `tests/rustdoc-gui/notable-trait.goml`

It also allowed me to add some new common test like:

```
        assert-position: (
            "//*[`@class='tooltip` popover']",
            {"x": |popover_x|}
        )
```

r? `@notriddle`
2024-04-23 06:24:56 +02:00
Guillaume Gomez
dd01f75a89 Move duplicated code in functions in tests/rustdoc-gui/notable-trait.goml 2024-04-20 14:53:14 +02:00
Guillaume Gomez
1ebc9efa78 Add GUI test for copy path button 2024-04-17 16:56:14 +02:00
Michael Howell
3a007dbea9 rustdoc: update test cases 2024-04-09 20:22:13 -07:00
Guillaume Gomez
66bc97cc88 Make theme switching closer to reality 2024-04-08 12:14:41 +02:00
Guillaume Gomez
53c5a69dfd Move check-container-color's code into check-search-color function 2024-04-06 15:52:00 +02:00
Guillaume Gomez
2b1c799636 Move duplicated code into check-search-color function 2024-04-06 15:47:12 +02:00
Guillaume Gomez
f14e4db1f9 Move more common code into a function in tests/rustdoc-gui/search-result-color.goml 2024-04-06 15:24:09 +02:00
Guillaume Gomez
4967895e55 Move search-result-color.goml common parts into a function 2024-04-06 14:53:30 +02:00
Guillaume Gomez
7659ef47f0 Use include command to reduce code duplication 2024-04-05 21:38:55 +02:00
Guillaume Gomez
a815b97850 Add regression test to ensure that even if JS is enabled but not working, a theme will still get applied 2024-04-04 23:49:34 +02:00
Guillaume Gomez
8f9d93bf57 Add GUI test to ensure there is always a theme applied if JS is disabled 2024-04-03 14:27:20 +02:00
Guillaume Gomez
0bb1ec729f Remove redundant code comments 2024-04-02 10:42:32 +02:00
Guillaume Gomez
59120d0ef5 Update to new browser-ui-test version 2024-04-01 22:25:01 +02:00
xiaoxiangxianzi
3157114f0b chore: fix some comments
Signed-off-by: xiaoxiangxianzi <zhaoyizheng@outlook.com>
2024-03-27 22:32:53 +08:00
许杰友 Jieyou Xu (Joe)
6e48b96692
[AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
Guillaume Gomez
5d29f5a6de Add regression test for #120471 to ensure that long crate name are handled as expected on mobile 2024-01-31 16:40:23 +01:00