Commit Graph

64 Commits

Author SHA1 Message Date
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 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 16fbf6a27b Add check for trait impl method anchor 2026-01-08 21:47:12 +01:00
Guillaume Gomez 985178dacf Add GUI test to ensure that negative impls are correctly sorted 2025-12-10 16:18:22 +01:00
Guillaume Gomez a21affabf8 Fix invalid link generation for type alias methods 2025-11-24 17:01:32 +01:00
Guillaume Gomez 6cccea8731 Remove doc_auto_cfg feature as well 2025-09-27 11:30:57 +02:00
Matthias Krüger 1285b164e1 Rollup merge of #147047 - notriddle:toolbar-index, r=GuillaumeGomez
rustdoc: put the toolbar on the all item index
2025-09-26 06:36:33 +02:00
Michael Howell 51ae86dec9 rustdoc-search: add test case for all/index.html search 2025-09-25 15:45:11 -07:00
León Orell Valerian Liehr 85c193a4ed rustdoc: hide #[repr(...)] if it isn't part of the public ABI 2025-09-25 11:49:27 +02:00
Guillaume Gomez b6f8824315 Ensure that --html-after-content option is used to check scrape_examples_ice rustdoc GUI test 2025-09-05 15:13:08 +02:00
Janis f67e29e5a8 squash fix render_call_locations panic when default span points at file outside of local_sources
add test against crashing with --html-after-content file

correctly add --html-after-content to env not args

formatting fix for rustdoc-call-locations-after-content/rmake.rs

Use local crate source file as default span in `render_call_locations`

- avoids unwrapping the first file added to the source map as a local file in
`href_from_span`

move test to tests/rustdoc-gui, rename to scrape_examples_ice

test link is correct

use rustdocflags, rename path in example, track lock file

factor out duplicate function calls

use compile-flags to make sure the after.html file is actually included in the rustdoc call

fix goml go-to path

increment assert-count in sidebar-source-code.goml

adjust crate-search width in search-result-display.goml

renamed Bar in scrape_examples_ice test

make crate name shorter ..
2025-09-02 01:38:23 +02:00
Guillaume Gomez 75cbd05d19 Add tests for doc(attribute = "...") attribute 2025-08-28 15:56:30 +02:00
Guillaume Gomez f5fddc776c Improve code and add test with macro coming from another file from the same crate 2025-08-23 10:57:14 +02:00
Guillaume Gomez e6f9e2e623 Add GUI test for --generate-macro-expansion option 2025-08-23 00:57:28 +02:00
Guillaume Gomez b4f404b581 Fix wrong font being used for tooltips i icons 2025-08-04 19:17:08 +02:00
SpecificProtagonist 31ae60d30d gui test 2025-05-10 19:36:28 +02:00
Guillaume Gomez a29072a67a Add/update GUI test for impl indent fix 2025-04-24 12:33:29 +02:00
Jacob Pratt 8133652562 Rollup merge of #136991 - GuillaumeGomez:code-wrapping, r=notriddle
[rustdoc] Add new setting to wrap source code lines when too long

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

Wrapped lines look like this:

![image](https://github.com/user-attachments/assets/92006a27-ed1e-4beb-91f2-f453b72c5e1a)

It works in both source code pages and doc pages.

You can test it [here](https://rustdoc.crud.net/imperio/code-wrapping/bar/index.html).

r? ``@notriddle``
2025-02-24 02:11:32 -05:00
yukang a467ecacd4 Add custom sort for link in rustdoc 2025-02-19 08:35:51 +08:00
Guillaume Gomez 38b5bfce24 Add GUI test for code wrapping 2025-02-14 11:41:28 +01:00
Guillaume Gomez caacb04830 Add GUI regression test for indent of trait items on mobile 2025-01-24 15:36:52 +01:00
Nicholas Nethercote 121e87bf14 Remove rustc::existing_doc_keyword lint.
`CheckAttrVisitor::check_doc_keyword` checks `#[doc(keyword = "..")]`
attributes to ensure they are on an empty module, and that the value is
a non-empty identifier.

The `rustc::existing_doc_keyword` lint checks these attributes to ensure
that the value is the name of a keyword.

It's silly to have two different checking mechanisms for these
attributes. This commit does the following.
- Changes `check_doc_keyword` to check that the value is the name of a
  keyword (avoiding the need for the identifier check, which removes a
  dependency on `rustc_lexer`).
- Removes the lint.
- Updates tests accordingly.

There is one hack: the `SelfTy` FIXME case used to used to be handled by
disabling the lint, but now is handled with a special case in
`is_doc_keyword`. That hack will go away if/when the FIXME is fixed.

Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
2024-12-17 13:56:10 +11:00
Guillaume Gomez 90feb9a645 Improve positioning of "..." in collapsed impl block 2024-12-05 22:50:21 +01:00
Guillaume Gomez 5d26accecd Add GUI test for impl block doc display 2024-12-05 22:50:21 +01:00
Guillaume Gomez 1c63ec9fa0 Add GUI regression test for #130622 and for #131223 2024-10-04 18:01:52 +02:00
Michael Howell 5b1b2e97e3 rustdoc: make the header show all three buttons
This tweaks it to use less space for the breadcrumbs.
2024-09-10 17:56:06 -07:00
Michael Howell d05323c7b4 rustdoc: redesign toolbar and disclosure widgets
This adds labels to the icons and moves them away from the search box.

These changes are made together, because they work together, but are based on
several complaints:

* The [+/-] thing are a Reddit-ism. They don't look like buttons, but look
  like syntax
  <https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/More.20visual.20difference.20for.20the.20.2B.2F-.20.20Icons>,
  <https://github.com/rust-lang/rust/issues/59851>
  (some of these are laundry lists with more suggestions, but they all
  mention [+/-] looking wrong)

* The settings, help, and summary buttons are also too hard to recognize
  <https://lwn.net/Articles/987070/>,
  <https://github.com/rust-lang/rust/issues/90310>,
  <https://github.com/rust-lang/rust/issues/14475#issuecomment-274241997>,
  <https://internals.rust-lang.org/t/improve-rustdoc-design/12758>
  ("Not all functionality is self-explanatory, for example the [+] button in
  the top right corner, the theme picker or the settings button.")

The toggle-all and toggle-individual buttons both need done at once, since we
want them to look like they go together. This changes them from both being
[+/-] to both being arrows.

Settings and Help are also migrated, so that the whole group can benefit from
being described using actual words.

Additionally, the Help button is only shown on SERPs, not all the time.
This is done for two major reasons:

* Most of what's in there is search-related. The things that aren't are
  keyboard commands, and the search box tells you about that anyway.
  Pressing <kbd>?</kbd> will temporarily show the button and its popover.
* I'm trading it off by showing the help button, even on mobile.
  It's useful since you can use the search engine suggestions there.
* The three buttons were causing line wrapping on too many desktop layouts.
2024-09-10 17:56:05 -07:00
Matthias Krüger 9be97ae8e2 Rollup merge of #129796 - GuillaumeGomez:unify-code-examples, r=notriddle
Unify scraped examples with other code examples

Fixes #129763.

This first PR both fixes #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```
2024-09-05 18:58:56 +02:00
Matthias Krüger c90991db17 Rollup merge of #127474 - tesuji:foldable-inline-derefs, r=t-rustdoc
doc: Make block of inline Deref methods foldable

After:
![image](https://github.com/rust-lang/rust/assets/15225902/3e8ab320-dbf7-436f-9be0-d0ef82664663)
Before:
![image](https://github.com/rust-lang/rust/assets/15225902/f6f7635d-d4c3-437e-a2d9-147726287b05)

Fix  #127470.

Current status:
- [x] Bug when hovering over title "Methods from ...": The anchor sign $ overlaps with `[-]`: https://github.com/rust-lang/rust/pull/127474#issuecomment-2222930038
    => Fixed by https://github.com/rust-lang/rust/pull/127474#issuecomment-2228886292
2024-09-02 04:19:27 +02:00
Guillaume Gomez 4825fb198f Add missing CSS variables in GUI test for custom-theme.css 2024-09-01 20:49:41 +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 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 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 c820a2392c Add test for size of items in the items list 2024-07-18 20:48:20 +02:00
Guillaume Gomez 9855a3844b Add tests for new toggle on deref blocks 2024-07-15 20:07:24 +02:00
Guillaume Gomez 0cbebd07ee Fix bad color for setting cog in ayu theme 2024-05-05 20:07:12 +02:00
许杰友 Jieyou Xu (Joe) 6e48b96692 [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
bors 67b6975051 Auto merge of #119066 - notriddle:notriddle/sidebar-source-redesign, r=GuillaumeGomez
rustdoc: clean up source sidebar hide button

This is a redesign of the feature, with parts pulled from https://github.com/rust-lang/rust/pull/119049 but with a button that looks more like a button and matches the one used on other sidebar pages.

Preview:

* http://notriddle.com/rustdoc-html-demo-8/source-sidebar-resize/src/std/lib.rs.html
* http://notriddle.com/rustdoc-html-demo-8/source-sidebar-resize/std/index.html

| | Before | After |
|--|--|--|
| Closed | ![image](https://github.com/rust-lang/rust/assets/1593513/092bed75-79c3-412f-8e7b-557f30dfb1e3) | ![image](https://github.com/rust-lang/rust/assets/1593513/b68e1ee9-9aef-484d-a5b1-2fd29c9d72ea)
| Open | ![image](https://github.com/rust-lang/rust/assets/1593513/95cf9545-25b1-48ec-820b-02e1aec99839) | ![image](https://github.com/rust-lang/rust/assets/1593513/923532f6-59e0-4d7c-9976-21699c30d42e)
| Mobile Closed | ![image](https://github.com/rust-lang/rust/assets/1593513/9bc00cc5-937c-4120-94be-94c7cb6d5297) | ![image](https://github.com/rust-lang/rust/assets/1593513/76a744d8-aac2-46fe-abb9-3b34e2d3ccaa)
| Mobile Open | ![image](https://github.com/rust-lang/rust/assets/1593513/d19a94fe-47b1-462d-a280-44fc215b9b72) | ![image](https://github.com/rust-lang/rust/assets/1593513/2b2e3dec-b610-4b12-8a72-35b86359ba45)
2023-12-31 15:32:15 +00:00
Guillaume Gomez 98b71bf345 Add GUI regression test for position of warning block 2023-12-24 19:24:04 +01:00
Michael Howell 9566db1e49 Fix corner cases when dealing with mobile mode 2023-12-19 19:50:53 -07:00
Guillaume Gomez f8b92697a1 Rollup merge of #115660 - notriddle:notriddle/sidebar-resize, r=GuillaumeGomez
rustdoc: allow resizing the sidebar / hiding the top bar

Fixes #97306

Preview: http://notriddle.com/rustdoc-html-demo-4/sidebar-resize/std/index.html

![image](https://github.com/rust-lang/rust/assets/1593513/a2f40ea2-0436-4e44-99e8-d160dab2a680)

## Summary

This feature adds:

1. A checkbox to the Settings popover to hide the persistent navigation bar (the sidebar on large viewports and the top bar on small ones).
2. On large viewports, it adds a resize handle to the persistent sidebar. Resizing it into nothing is equivalent to turning off the persistent navigation bar checkbox in Settings.
3. If the navigation bar is hidden, a toolbar button to the left of the search appears. Clicking it brings the navigation bar back.

## Motivation

While "mobile mode" is definitely a good default, it's not the only reason people have wanted to hide the sidebar:

* Some people use tiling window managers, and don't like rustdoc's current breakpoints. Changing the breakpoints might help with that, but there's no perfect solution, because there's a gap between "huge screen" and "smartphone" where reasonable people can disagree about whether it makes sense for the sidebar to be on-screen. https://github.com/rust-lang/rust/issues/97306

* Some people ask for ways to reduce on-screen clutter because it makes it easier to focus. There's not a media query for that (and if there was, privacy-conscious users would turn it off). https://github.com/rust-lang/rust/issues/59829

This feature is designed to avoid these problems. Resizing the sidebar especially helps, because it provides a way to hide the sidebar without adding a new top-level button (which would add clutter), and it provides a way to make rustdoc play nicer in complex, custom screen layouts.

## Guide and Reference-level explanation

On a desktop or laptop with a mouse, resize the sidebar by dragging its right edge.

On any browser, including mobile phones, the sticky top bar or side bar can be hidden from the Settings area (the button with the cog wheel, next to the search bar). When it's hidden, a convenient button will appear on the search bar's left.

## Drawbacks

This adds more JavaScript code to the render blocking area.

## Rationale and alternatives

The most obvious way to allow people to hide the sidebar would have been to let them "manually enter mobile mode." The upside is that it's a feature we already have. The downside is that it's actually really hard to come up with a terse description. Is it:

* A Setting that forces desktop viewers to always have the mobile-style top bar? If so, how do we label it? Should it be visible on mobile, and, if so, does it just not do anything?
* A persistent hide/show sidebar button, present on desktop, just like on mobile? That's clutter that I'd like to avoid.

## Prior art

* The new file browser in GitHub uses a similar divider with a mouse-over indicator
* mdBook and macOS Finder both allow you to resize the sidebar to nothing as a gesture to hide it
* https://www.nngroup.com/articles/drag-drop/

## Future possibilities

https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Table.20of.20contents proposes a new, second sidebar (a table of contents). How should it fit in with this feature? Should it be resizeable? Hideable? Can it be accessed on mobile?
2023-12-15 11:51:23 +01:00
Guillaume Gomez 9e1797baf1 Extend GUI tests for doc_cfg 2023-12-07 10:44:55 +01:00
Guillaume Gomez 768a614380 Add GUI tests for comments highlighting in items declaration 2023-12-01 11:23:38 +01:00
Guillaume Gomez 2e4a36bb53 Add GUI test to ensure that implementations on foreign types are in the expected order 2023-11-02 18:02:14 +01:00
Oli Scherer 4512f211ae Accept less invalid Rust in rustdoc 2023-10-31 13:58:03 +00:00
Michael Howell 46fdeb24fd rustdoc: make JS trait impls act more like HTML 2023-10-22 16:51:32 -07:00