Commit Graph

411 Commits

Author SHA1 Message Date
mejrs
6ef144dcb3 rustdoc: use anonymous constant for primitives/keywords/attribute docs 2026-08-13 14:49:49 +02:00
Jacob Pratt
4debf0889f Rollup merge of #160438 - GuillaumeGomez:table-odd-code, r=notriddle,lolbinarycat
[rustdoc] Change table odd table rows background color to not make it the same as inline code

Fixes rust-lang/rust#159234.
Follow-up of https://github.com/rust-lang/rust/pull/105442.

It now looks like this:

<img width="418" height="163" alt="Screenshot From 2026-08-03 15-21-15" src="https://github.com/user-attachments/assets/97d2ae1c-e167-4cc0-8daf-d8937397faed" />
<img width="418" height="163" alt="Screenshot From 2026-08-03 15-21-21" src="https://github.com/user-attachments/assets/8916a49d-2496-4045-820a-12f10f18d81b" />
<img width="418" height="163" alt="Screenshot From 2026-08-03 15-21-25" src="https://github.com/user-attachments/assets/b44b3b3f-8ec7-4fea-b783-aedf1b452249" />

For the light theme, I had to make the inline code background darker so it would mix well with the alternative table rows background color.

r? @notriddle
2026-08-12 20:17:27 -04:00
Guillaume Gomez
e7e5245db1 Invert table row background 2026-08-12 23:09:20 +02:00
Guillaume Gomez
e647d65faf Change table odd table rows background color to not make it the same as inline code 2026-08-12 22:56:05 +02:00
Guillaume Gomez
5dc184c1ae rustdoc: Fix invalid CSS classes generated for notable items 2026-08-11 17:57:15 +02:00
Jacob Pratt
dccf2ca6a0 Rollup merge of #160091 - GuillaumeGomez:rustdoc-toolbar-buttons, r=notriddle
Fix rustdoc toolbar height when title is taller than one line

Fixes https://github.com/rust-lang/rust/issues/160086.

With the fix:

<img width="814" height="238" alt="image" src="https://github.com/user-attachments/assets/5a8edb52-bc6e-44e7-943c-85a73f21e81e" />

r? @notriddle
2026-07-28 20:09:38 -04:00
Guillaume Gomez
e9ca1abeed Add regression test for rustdoc toolbar buttons height 2026-07-28 18:11:54 +02:00
Guillaume Gomez
1d3222031e Add missing "clipboard-read" permission 2026-07-28 11:11:00 +02:00
Jana Dönszelmann
25745ee1f1 fix all tidy annotations 2026-07-13 10:54:53 +02:00
Guillaume Gomez
2262b8e226 Fix bug when rustdoc "go to only result" setting is not working as expected" 2026-06-23 17:12:08 +02:00
Rob
8e9173fc3c librustdoc: update test to fix CSS border issue to support Firefox high contrast mode 2026-06-03 11:05:15 -06:00
Nicholas Nethercote
eef3ae7817 rustdoc: Fix trait impl ordering
For types, rustdoc produces different impl orderings in the sidebar vs.
the main section.

E.g. for `std::cell::UnsafeCell` the "Trait Implementations" sidebar
order is this:
```
!Freeze
!RefUnwindSafe
!Sync
CoerceUnsized<UnsafeCell<U>>
Debug
Default
DispatchFromDyn<UnsafeCell<U>>
From<T>
```
The primary sort is on polarity, and the secondary sort is alphabetical.
Makes sense.

The main section order is this:
```
impl<T> Debug for UnsafeCell<T>
impl<T> Default for UnsafeCell<T>
impl<T> From<T> for UnsafeCell<T>
impl<T, U> CoerceUnsized<UnsafeCell<U>> for UnsafeCell<T>
impl<T, U> DispatchFromDyn<UnsafeCell<U>> for UnsafeCell<T>
impl<T> !Freeze for UnsafeCell<T>
impl<T> !RefUnwindSafe for UnsafeCell<T>
impl<T> !Sync for UnsafeCell<T>
```
This strange ordering occurs because the entries are sorted on the
generated HTML. Impls with methods (the first three) come first because
they start with a `<details>` tag while the others start with a
`<section>` tag. After that, the order depends on a section id of the
form `impl-{trait}-for-{type}` that doesn't include the polarity, which
is why the secondary ordering is alphabetical but ignores the `!`.

The sidebar ordering is the better of the two. This commit changes the
main section to use the same ordering as the sidebar. This involves
creating a new function `impl_trait_key` shared between the two parts.
2026-06-02 13:04:49 +10:00
Nicholas Nethercote
9119e3c2b1 rustdoc: Add a test for trait impl ordering
This shows how the ordering in the sidebar and the main section differ.
The next commit will fix this inconsistency.
2026-06-02 13:04:45 +10:00
Nicholas Nethercote
8fab72f473 rustdoc: Fix comment in sidebar-foreign-impl-sort.goml 2026-06-02 13:01:20 +10:00
Jonathan Brouwer
b0d9ae60e1 Rollup merge of #156401 - shivendra02467:doc-cfg-sort-fix, r=GuillaumeGomez
rustdoc: deterministic sorting for `doc_cfg` badges

Fixes rust-lang/rust#156391

Currently, target-exclusive `doc_cfg` badges (eg. "Available on...") reuse the order of predicates as they appear in the source code. This often buries popular targets behind niche ones and leads to inconsistent UI rendering.

This PR introduces a deterministic sorting mechanism to the `Cfg` AST prior to HTML/JSON rendering.

**Note for Reviewers:**
To provide the best UX, I implemented a lightweight tiering heuristic (prioritizing major platforms like Linux/Apple/Windows first, followed by mobile, then BSDs, and alphabetizing the rest). However, I am completely open to tweaking these priority groupings or falling back to a different sorting logic if the team prefers. Let me know what you think!
2026-05-28 14:59:41 +02:00
Shivendra Sharma
f658bf6bb8 rustdoc: deterministic sorting for doc_cfg badges 2026-05-28 16:15:20 +05:30
Guillaume Gomez
1cbb922c16 Change HTML IDs for attribute macros and attributes
Rename `ItemType::BangMacro*` into `ItemType::DeclMacro*`
Rename `isBangMacro` field into `forceMacroHref`
2026-05-10 02:37:58 +02:00
Guillaume Gomez
d0ff143b06 Correctly generate bang macro declaration in docs for attr/derive kinds 2026-05-10 02:37:58 +02:00
Guillaume Gomez
afcada6d03 Fix link to attr/derive bang macros 2026-05-10 02:37:57 +02:00
Guillaume Gomez
72abf90d22 Deduplicate "attributes" and "attribute macros" sections IDs 2026-05-10 02:37:57 +02:00
Guillaume Gomez
0299472949 Add tests for attribute bang macros in rustdoc 2026-05-10 02:37:57 +02:00
Guillaume Gomez
6c4ec59d5f Tweak how the "copy path" rustdoc button works to allow some accessibility tool to work with rustdoc 2026-04-16 22:06:45 +02:00
binarycat
9bdf217810 rustdoc: seperate methods and associated functions in sidebar 2026-03-31 12:51:12 -05:00
Sasha Pourcelot
9f0944832b rustdoc: add missing target_{os,arch,env} values for cfg pretty printer 2026-03-29 16:02:23 +00:00
Jonathan Brouwer
bce8c00e2f Remove the 4 failing tests from rustdoc-gui 2026-02-06 01:13:41 +01:00
Guillaume Gomez
607ac4bb84 Remove rustdoc GUI flaky test 2026-02-04 17:09:57 +01:00
Guillaume Gomez
4e4192aa48 Try to fix rustdoc-gui/globals.goml flakyness 2026-02-03 16:07:25 +01:00
Guillaume Gomez
9e5820379d Fix flakyness issue with tests/rustdoc-gui/globals.goml test 2026-01-30 11:22:19 +01:00
Stuart Cook
3830f76b4a Rollup merge of #151665 - arferreira:fix-rustdoc-contrast, r=GuillaumeGomez
Fix contrast ratio for `Since` element in rustdoc dark theme

Changed `--right-side-color` from `#808080` to `#ababab` in the dark theme.

<img width="742" height="784" alt="Screenshot 2026-01-25 at 8 04 29 PM" src="https://github.com/user-attachments/assets/38c5f0b9-2034-429f-87db-8a0ed8209b5d" />

Verified visually in dark theme, it's now more readable:

<img width="174" height="96" alt="Screenshot 2026-01-25 at 8 41 02 PM" src="https://github.com/user-attachments/assets/d0c30409-4374-48c4-ae9c-a0aec48e8957" />

Part of https://github.com/rust-lang/rust/issues/59845
Fixes rust-lang/rust#151422
2026-01-29 19:03:32 +11:00
Stuart Cook
f5822b672b Rollup merge of #151559 - GuillaumeGomez:marker-hidden-deprecated-search, r=lolbinarycat
[rustdoc] Add a marker to tell users that there are hidden (deprecated) items in the search results

Someone on mastodon rightfully pointed out that having a visual indication that some search results were hidden would be a good idea if the "hide deprecated items" setting is enabled. In particular if no results are displayed.

It looks like this:

<img width="861" height="228" alt="Screenshot From 2026-01-24 00-26-33" src="https://github.com/user-attachments/assets/93aeef11-a550-47dc-9c78-219ea4fd822c" />

r? @lolbinarycat
2026-01-29 19:03:31 +11:00
Guillaume Gomez
21ebd03e5e Try to reduce rustdoc GUI tests flakyness 2026-01-26 16:18:36 +01:00
Antonio Souza
c7788af89a Fix contrast ratio for Since element in rustodoc dark theme
Signed-off-by: Antonio Souza <arfs.antonio@gmail.com>
2026-01-26 06:53:53 -05:00
Guillaume Gomez
0e240d3232 Add GUI regression test for the display and content of the "hidden deprecated item marker" 2026-01-24 12:19:14 +01:00
ThanhNguyxn
78afe876f4 Add 'Skip to main content' link for keyboard navigation in rustdoc
Implements WCAG 2.4.1 (Level A) - Bypass Blocks accessibility feature.

Changes:
- Add skip-main-content link in page.html with tabindex=-1 on main-content
- Add CSS styling per reviewer feedback (outline border, themed colors)
- Add GOML test for skip navigation functionality

Fixes #151420
2026-01-23 18:19:00 +07:00
Guillaume Gomez
d5bacddca9 Update GUI test to new number of settings and add note about it 2026-01-20 15:58:34 +01:00
Guillaume Gomez
76ea822db2 Add rustdoc GUI regression test for #151209 2026-01-20 14:35:38 +01:00
Stuart Cook
88df8fd3ef Rollup merge of #151091 - hide-deprecated-items, r=lolbinarycat
Add new "hide deprecated items" setting in rustdoc

This PR adds a new JS setting which allows the JS to hide deprecated items. This is especially useful for crates like `std` which accumulates deprecated items but never removes them.

Nicely enough, the "deprecation" information was already in the search index, meaning I didn't need to change anything there. Before this PR, it was only used to make the deprecated items rank lower. Well now it's also used to generate an extra CSS class, allowing the JS setting to work.

This is taking over https://github.com/rust-lang/rust/pull/149551.

This feature got approved by the rustdoc team in the [meeting of december](https://rust-lang.zulipchat.com/#narrow/channel/393423-t-rustdoc.2Fmeetings/topic/2025-12-08/near/562553156).

You can give it a try [here](https://rustdoc.crud.net/imperio/hide-deprecated-items/foo/index.html).

r? @lolbinarycat
2026-01-20 18:00:09 +11:00
Guillaume Gomez
aef8112b26 Add test for search results of not yet deprecated search items
Improve the `perform-search` goml function to work when search is already open
2026-01-19 23:14:09 +01:00
Guillaume Gomez
9f965bcf76 Add rustdoc GUI test to ensure that the "hide deprecated items" setting is working as expected 2026-01-19 21:37:15 +01:00
Guillaume Gomez
4bacdf7b8b Reduce rustdoc GUI flakyness, take 2 2026-01-14 22:47:53 +01:00
Guillaume Gomez
62849e6441 Reduce flakyness for tests/rustdoc-gui/notable-trait.goml 2026-01-13 10:22:34 +01:00
Guillaume Gomez
fe307c5452 Rollup merge of #150816 - method-anchor, r=camelid
Fix trait method anchor disappearing before user can click on it

A good example of this bug is going to https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/collect/struct.ItemCtxt.html#impl-HirTyLowerer%3C'tcx%3E-for-ItemCtxt%3C'tcx%3E, and then try to click on the `§` anchor of the `tcx` method.

The solution to this bug is to simply "glue" the anchor to the method, so when the mouse cursor moves to it, there is no gap between the two, preventing the anchor to disappear (hopefully this explanation doesn't make sense only to me ^^').

First commit fixes the bug by expanding the anchor size.
Second commit is a small clean-up of the GUI test.
Third commit actually adds the GUI regression test.

cc @BoxyUwU
r? @camelid
2026-01-09 12:00:01 +01:00
Guillaume Gomez
945e7c78d2 Use functions more in rustdoc GUI tests 2026-01-08 21:49:29 +01:00
Guillaume Gomez
16fbf6a27b Add check for trait impl method anchor 2026-01-08 21:47:12 +01:00
Guillaume Gomez
bfb117ac74 Clean up tests/rustdoc-gui/anchors.goml test code 2026-01-08 21:47:12 +01:00
Guillaume Gomez
c502d7fce0 Fix trait method anchor disappearing before user can click on it 2026-01-08 21:47:12 +01:00
Guillaume Gomez
665781513e Fix changes coming from browser-ui-test version update 2026-01-02 20:21:44 +01:00
Jonathan Brouwer
71c248a2e1 Rollup merge of #150396 - GuillaumeGomez:fix-line-numbers-hidden, r=lolbinarycat
[rustdoc] If line number setting is disabled, do not make line numbers take space

While working on https://github.com/rust-lang/rust/pull/150395, I realized that when enabled then disabled the "show line numbers" setting, instead of looking like initially:

<img width="904" height="148" alt="Screenshot From 2025-12-26 16-51-44" src="https://github.com/user-attachments/assets/a24df2f2-61be-4db5-b60f-519b35425fd2" />

The "space" taken by line numbers was still there:

<img width="904" height="148" alt="Screenshot From 2025-12-26 16-51-41" src="https://github.com/user-attachments/assets/b44af75d-52a4-4401-98e4-602b16bf6b9b" />

This PR fixes it.

First commit cleans up the `utils.goml` file a bit, I think I'll do more cleanup because switching the settings without reloading the page should make GUI tests a bit faster.

r? `@yotamofek`
2025-12-30 02:07:07 +01:00
Guillaume Gomez
c054e52bc9 Add GUI test for copying code when line numbers are displayed in code examples 2025-12-26 20:24:50 +01:00
Guillaume Gomez
99836fc6d4 Add GUI regression test for disabled line numbers 2025-12-26 20:13:27 +01:00