about summary refs log tree commit diff
path: root/tests/rustdoc-gui
AgeCommit message (Collapse)AuthorLines
2024-05-07Rollup merge of #124738 - notriddle:notriddle/search-form-js, r=GuillaumeGomezMatthias Krüger-2/+2
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-05Add GUI regression test for setting's cog colorGuillaume Gomez-1/+31
2024-05-05Fix bad color for setting cog in ayu themeGuillaume Gomez-0/+1
2024-05-05rustdoc: dedup search form HTMLMichael Howell-2/+2
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-04-23Rollup merge of #124197 - GuillaumeGomez:move-duplicated-code, r=notriddleMatthias Krüger-119/+89
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-20Move duplicated code in functions in `tests/rustdoc-gui/notable-trait.goml`Guillaume Gomez-119/+89
2024-04-17Add GUI test for copy path buttonGuillaume Gomez-0/+15
2024-04-09rustdoc: update test casesMichael Howell-4/+4
2024-04-08Make theme switching closer to realityGuillaume Gomez-20/+34
2024-04-06Move `check-container-color`'s code into `check-search-color` functionGuillaume Gomez-31/+19
2024-04-06Move duplicated code into `check-search-color` functionGuillaume Gomez-218/+98
2024-04-06Move more common code into a function in ↵Guillaume Gomez-30/+44
`tests/rustdoc-gui/search-result-color.goml`
2024-04-06Move `search-result-color.goml` common parts into a functionGuillaume Gomez-69/+52
2024-04-05Use `include` command to reduce code duplicationGuillaume Gomez-150/+112
2024-04-04Add regression test to ensure that even if JS is enabled but not working, a ↵Guillaume Gomez-0/+9
theme will still get applied
2024-04-03Add GUI test to ensure there is always a theme applied if JS is disabledGuillaume Gomez-0/+5
2024-04-02Remove redundant code commentsGuillaume Gomez-72/+72
2024-04-01Update to new browser-ui-test versionGuillaume Gomez-248/+266
2024-03-27chore: fix some commentsxiaoxiangxianzi-1/+1
Signed-off-by: xiaoxiangxianzi <zhaoyizheng@outlook.com>
2024-02-22[AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives许杰友 Jieyou Xu (Joe)-4/+4
2024-01-31Add regression test for #120471 to ensure that long crate name are handled ↵Guillaume Gomez-2/+24
as expected on mobile
2024-01-22Rollup merge of #119746 - notriddle:notriddle/resize-close-modals, r=fmeaseMatthias Krüger-0/+20
rustdoc: hide modals when resizing the sidebar Follow-up for https://github.com/rust-lang/rust/pull/119477#discussion_r1439085011 CC `@lukas-code`
2024-01-19Rollup merge of #117662 - GuillaumeGomez:links-in-headings, r=notriddleMatthias Krüger-5/+37
[rustdoc] Allows links in headings Reopening of https://github.com/rust-lang/rust/pull/94360. # Explanations Rustdoc currently doesn't follow the markdown spec on headings: we don't allow links in them. So instead of having headings linking to themselves, this PR generates an anchor on the left side like this: ![image](https://github.com/rust-lang/rust/assets/3050060/a118a7e9-5ef8-4d07-914f-46defc3245c3) <details> <summary>previous version</summary> ![image](https://github.com/rust-lang/rust/assets/3050060/c34fa844-9cd4-47dc-bb51-b37f5f66afee) </details> Having the anchor always displayed allows for mobile devices users to be able to have a link to the anchor. The different color used for the anchor itself is the same as links so people notice when looking at it that they can click on it. You can test it [here](https://rustdoc.crud.net/imperio/links-in-headings/std/index.html). cc `@camelid` r? `@notriddle`
2024-01-08rustdoc: hide modals when resizing the sidebarMichael Howell-0/+20
Follow-up for https://github.com/rust-lang/rust/pull/119477#discussion_r1439085011
2023-12-31rustdoc ui: adjust tooltip z-index to be above sidebarLukas Markeffsky-0/+12
2023-12-31Auto merge of #119066 - notriddle:notriddle/sidebar-source-redesign, ↵bors-92/+60
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-26rustdoc: treat query string `+` as spaceMichael Howell-0/+9
Fixes #119219
2023-12-24Add GUI regression test for position of warning blockGuillaume Gomez-0/+16
2023-12-19Fix corner cases when dealing with mobile modeMichael Howell-0/+29
2023-12-18Use folder icon instead of hamburger and sidebarMichael Howell-3/+6
2023-12-18Stop using the trigram of heaven as a hamburger buttonMichael Howell-2/+2
It doesn't look quite right, because the lines are too far apart, and it's not going to be announced by screenreaders as a menu button, since that's not what the symbol means. This adds a real tooltip and uses a better drawing of the icon.
2023-12-18Add back the columnMichael Howell-45/+16
2023-12-17rustdoc: clean up source sidebar hide buttonMichael Howell-54/+19
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.
2023-12-15Rollup merge of #118988 - notriddle:notriddle/varconst, r=GuillaumeGomezMatthias Krüger-0/+24
rustdoc: add regression test for JS data file loading Follow up for #118961
2023-12-15rustdoc: add regression test for JS data file loadingMichael Howell-0/+24
Follow up for #118961
2023-12-15Rollup merge of #115660 - notriddle:notriddle/sidebar-resize, r=GuillaumeGomezGuillaume Gomez-7/+118
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-07Extend GUI tests for `doc_cfg`Guillaume Gomez-0/+31
2023-12-05Add tests for headings anchor and links in headingsGuillaume Gomez-4/+36
2023-12-05Update rustdoc headings testsGuillaume Gomez-1/+1
2023-12-01Add GUI tests for comments highlighting in items declarationGuillaume Gomez-1/+118
2023-11-30rustdoc: `div.where` instead of fmt-newline classMichael Howell-4/+4
This is about equally readable, a lot more terse, and stops special-casing functions and methods. ```console $ du -hs doc-old/ doc-new/ 671M doc-old/ 670M doc-new/ ```
2023-11-29rustdoc: remove small from `small-section-header`Michael Howell-2/+2
There's no such thing as a big section header, so I don't know why the name was used.
2023-11-19rustdoc-search: add support for associated typesMichael Howell-1/+1
2023-11-02Add GUI test to ensure that implementations on foreign types are in the ↵Guillaume Gomez-1/+26
expected order
2023-10-31Accept less invalid Rust in rustdocOli Scherer-2/+7
2023-10-22rustdoc: make JS trait impls act more like HTMLMichael Howell-1/+68
2023-10-22rustdoc: remove as_ref from method sidebar testMichael Howell-6/+5
I fixed this in the code, but forgot to fix it in the test.
2023-10-22rustdoc: use JS to inline target type impl docs into aliasMichael Howell-0/+47
This is an attempt to balance three problems, each of which would be violated by a simpler implementation: - A type alias should show all the `impl` blocks for the target type, and vice versa, if they're applicable. If nothing was done, and rustdoc continues to match them up in HIR, this would not work. - Copying the target type's docs into its aliases' HTML pages directly causes far too much redundant HTML text to be generated when a crate has large numbers of methods and large numbers of type aliases. - Using JavaScript exclusively for type alias impl docs would be a functional regression, and could make some docs very hard to find for non-JS readers. - Making sure that only applicable docs are show in the resulting page requires a type checkers. Do not reimplement the type checker in JavaScript. So, to make it work, rustdoc stashes these type-alias-inlined docs in a JSONP "database-lite". The file is generated in `write_shared.rs`, included in a `<script>` tag added in `print_item.rs`, and `main.js` takes care of patching the additional docs into the DOM. The format of `trait.impl` and `type.impl` JS files are superficially similar. Each line, except the JSONP wrapper itself, belongs to a crate, and they are otherwise separate (rustdoc should be idempotent). The "meat" of the file is HTML strings, so the frontend code is very simple. Links are relative to the doc root, though, so the frontend needs to fix that up, and inlined docs can reuse these files. However, there are a few differences, caused by the sophisticated features that type aliases have. Consider this crate graph: ```text --------------------------------- | crate A: struct Foo<T> | | type Bar = Foo<i32> | | impl X for Foo<i8> | | impl Y for Foo<i32> | --------------------------------- | ---------------------------------- | crate B: type Baz = A::Foo<i8> | | type Xyy = A::Foo<i8> | | impl Z for Xyy | ---------------------------------- ``` The type.impl/A/struct.Foo.js JS file has a structure kinda like this: ```js JSONP({ "A": [["impl Y for Foo<i32>", "Y", "A::Bar"]], "B": [["impl X for Foo<i8>", "X", "B::Baz", "B::Xyy"], ["impl Z for Xyy", "Z", "B::Baz"]], }); ``` When the type.impl file is loaded, only the current crate's docs are actually used. The main reason to bundle them together is that there's enough duplication in them for DEFLATE to remove the redundancy. The contents of a crate are a list of impl blocks, themselves represented as lists. The first item in the sublist is the HTML block, the second item is the name of the trait (which goes in the sidebar), and all others are the names of type aliases that successfully match. This way: - There's no need to generate these files for types that have no aliases in the current crate. If a dependent crate makes a type alias, it'll take care of generating its own docs. - There's no need to reimplement parts of the type checker in JavaScript. The Rust backend does the checking, and includes its results in the file. - Docs defined directly on the type alias are dropped directly in the HTML by `render_assoc_items`, and are accessible without JavaScript. The JSONP file will not list impl items that are known to be part of the main HTML file already. [JSONP]: https://en.wikipedia.org/wiki/JSONP
2023-10-22Added a new item, need to bump this countMichael Howell-2/+2
2023-10-22rustdoc: rename `/implementors` to `/impl.trait`Michael Howell-6/+6
This is shorter, avoids potential conflicts with a crate named `implementors`[^1], and will be less confusing when JS include files are added for type aliases. [^1]: AFAIK, this couldn't actually cause any problems right now, but it's simpler just to make it impossible than relying on never having a file named `trait.Foo.js` in the crate data area.