about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2024-08-09Rollup merge of #128834 - its-the-shrimp:fix_101105, r=aDotInTheVoidMatthias Krüger-1/+8
rustdoc: strip unreachable modules Modules are now stripped based on the same logic that's used to strip other item kinds Fixes #101105
2024-08-08rustdoc: do not run doctests with invalid langstringsMichael Howell-7/+19
2024-08-08fix typos, more SelfEtomicBomb-17/+13
typos in comments, remove references to crate-info, Self type in ordered_json and sorted_template
2024-08-08rustdoc: fixed #101105schvv31n-1/+8
modules are now stripped based on the same logic that's used to strip other item kinds
2024-08-08review commentsEsteban Küber-2/+2
2024-08-08Split `ColorConfig` off of `HumanReadableErrorType`Esteban Küber-7/+9
The previous setup tied two unrelated things together. Splitting these two is a better model.
2024-08-07rename sortedjson -> orderedjsonEtomicBomb-193/+228
2024-08-07added unit tests for write_sharedEtomicBomb-51/+257
2024-08-07move sorted_template and sorted_json testsEtomicBomb-272/+271
2024-08-07add blank line, remove extraneous commentEtomicBomb-1/+1
2024-08-07initial implementation of mergable rustdoc cciEtomicBomb-685/+1317
2024-08-06Rollup merge of #128736 - GuillaumeGomez:fix-remap-path-prefix, r=notriddleMatthias Krüger-0/+2
Fix rustdoc missing handling of remap-path-prefix option Fixes https://github.com/rust-lang/rust/issues/69264. cc `@weihanglo` r? `@notriddle`
2024-08-06Rollup merge of #128693 - notriddle:notriddle/impl-disambiguator-2024, ↵Matthias Krüger-6/+12
r=GuillaumeGomez rustdoc-search: account for numeric disambiguators on impls Fixes #128676
2024-08-06Fix rustdoc missing handling of `remap-path-prefix` optionGuillaume Gomez-0/+2
2024-08-06rustdoc-search: account for numeric disambiguators on implsMichael Howell-6/+12
Fixes #128676
2024-08-05Rollup merge of #128385 - its-the-shrimp:fix_114039, r=aDotInTheVoidMatthias Krüger-29/+15
rustdoc-json: discard non-local inherent impls for primitives Fixes #114039 at least it should r? `@aDotInTheVoid`
2024-08-05rustdoc-json: discard non-local inherent implsschvv31n-29/+15
2024-08-05Prevent clicking on a link or on a button to toggle the code example buttons ↵Guillaume Gomez-2/+6
visibility
2024-08-05Unify run button display with "copy code" button and with mdbook buttonsGuillaume Gomez-42/+23
2024-08-04rustdoc: Delete `ReceiverTy` (formerly known as `SelfTy`)Noah Lev-45/+18
It was barely used, and the places that used it are actually clearer without it since they were often undoing some of its work. This also avoids an unnecessary clone of the receiver type and removes a layer of logical indirection in the code.
2024-08-04Use `match` instead of sequence of `if let`sNoah Lev-234/+243
This is much more readable and idiomatic, and also may help performance since `match`es usually use switches while `if`s may not. I also fixed an incorrect comment.
2024-08-04rustdoc: Stop treating `Self` as a generic in search indexNoah Lev-6/+1
We already have special-cased code to handle inlining `Self` as the type or trait it refers to, and this was just causing glitches like the search `A -> B` yielding blanket `Into` impls.
2024-08-04rustdoc: Create `SelfTy` to replace `Generic(kw::SelfUpper)`Noah Lev-25/+35
Rustdoc often has to special-case `Self` because it is, well, a special type of generic parameter (although it also behaves as an alias in concrete impls). Instead of spreading this special-casing throughout the code base, create a new variant of the `clean::Type` enum that is for `Self` types. This is a refactoring that has almost no impact on rustdoc's behavior, except that `&Self`, `(Self,)`, `&[Self]`, and other similar occurrences of `Self` no longer link to the wrapping type (reference primitive, tuple primitive, etc.) as regular generics do. I felt this made more sense since users would expect `Self` to link to the containing trait or aliased type (though those are usually expanded), not the primitive that is wrapping it. For an example of the change, see the docs for `std::alloc::Allocator::by_ref`.
2024-08-04rustdoc: Rename `SelfTy` to `ReceiverTy`Noah Lev-13/+13
`SelfTy` makes it sound like it is literally the `Self` type, whereas in fact it may be `&Self` or other types. Plus, I want to use the name `SelfTy` for a new variant of `clean::Type`. Having both causes resolution conflicts or at least confusion.
2024-08-04Rollup merge of #128620 - GuillaumeGomez:update-rinja, r=notriddleMatthias Krüger-1/+1
Update rinja version to 0.3.0 r? ```@notriddle```
2024-08-04Rollup merge of #128615 - notriddle:notriddle/anchor-a11y, r=GuillaumeGomezMatthias Krüger-1/+1
rustdoc: make the hover trail for doc anchors a bit bigger https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Weird.20markdown.20heading.20rendering.3F r? ```@GuillaumeGomez``` ### Screenshots (the purple part is the padding, which the mouse can pass through to hover over it) | Before | After | |--|--| | ![image](https://github.com/user-attachments/assets/5070eebe-84ac-4f5d-8950-58664370191c) | ![image](https://github.com/user-attachments/assets/55340161-ad8a-41bd-a120-8cdab11f4af0)
2024-08-04Rollup merge of #128578 - camelid:cache-index-cleanup, r=notriddleMatthias Krüger-157/+167
rustdoc: Cleanup `CacheBuilder` code for building search index This code was very convoluted and hard to reason about. It is now (I hope) much clearer and more suitable for both future enhancements and future cleanups. I'm doing this as a precursor, with no UI changes, to changing rustdoc to [ignore blanket impls][1] in type-based search. [1]: https://github.com/rust-lang/rust/pull/128471#discussion_r1699475342 r? ``@notriddle``
2024-08-03rustdoc: Re-add missing `stripped_mod` check; explain orphan implsNoah Lev-5/+26
Co-authored-by: Michael Howell <michael@notriddle.com>
2024-08-04Update rinja version to 0.3.0Guillaume Gomez-1/+1
2024-08-03rustdoc: make the hover trail for doc anchors a bit biggerMichael Howell-1/+1
https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Weird.20markdown.20heading.20rendering.3F
2024-08-03Rollup merge of #128573 - GuillaumeGomez:simplify-body, r=notriddleMatthias Krüger-5/+3
Simplify `body` usage in rustdoc No changes, just a little less code. r? `@notriddle`
2024-08-03Simplify `body` usage in rustdocGuillaume Gomez-5/+3
2024-08-02Restructure `add_item_to_search_index` to eliminate code pathsNoah Lev-110/+103
Many of the code paths it handled were actually impossible. In other cases, the various checks and transformations were spread around in such a way that it was hard to tell what was going on.
2024-08-02Extract local variablesNoah Lev-30/+33
2024-08-02Restructure a confusing `match`Noah Lev-62/+62
2024-08-02rustdoc: Simplify some search index codeNoah Lev-44/+36
2024-08-02rustdoc: Clarify construction of name for search indexNoah Lev-11/+14
2024-08-02rustdoc: Extract helper function to add item to search indexNoah Lev-137/+135
2024-08-01rustdoc: Remove dead opaque_tys rendering logicAlona Enraght-Moony-11/+0
2024-08-01rustdoc: Remove OpaqueTyAlona Enraght-Moony-64/+6
2024-07-30Rollup merge of #128339 - GuillaumeGomez:click-code-example, r=notriddleMatthias Krüger-3/+37
[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-29Make the buttons remain when code example is clickedGuillaume Gomez-3/+37
2024-07-29rustdoc: move the wbr after the underscore, instead of beforeMichael Howell-8/+8
2024-07-29rustdoc: properly handle path wrappingMichael Howell-4/+19
2024-07-29rustdoc: use `<wbr>` in sidebar headersMichael Howell-4/+24
This also improves sidebar layout, so instead of BTreeM ap you get this BTree Map
2024-07-29rustdoc: avoid redundant HTML when there's already line breaksMichael Howell-0/+10
2024-07-29rustdoc: word wrap CamelCase in the item list tableMichael Howell-4/+107
This is an alternative to ee6459d6521cf6a4c2e08b6e13ce3c6ce5d55ed0. That is, it fixes the issue that affects the very long type names in https://docs.rs/async-stripe/0.31.0/stripe/index.html#structs. This is, necessarily, a pile of nasty heuristics. We need to balance a few issues: - Sometimes, there's no real word break. For example, `BTreeMap` should be `BTree<wbr>Map`, not `B<wbr>Tree<wbr>Map`. - Sometimes, there's a legit word break, but the name is tiny and the HTML overhead isn't worth it. For example, if we're typesetting `TyCtx`, writing `Ty<wbr>Ctx` would have an HTML overhead of 50%. Line breaking inside it makes no sense.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-320/+270
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28Rollup merge of #125779 - GuillaumeGomez:copy-code, r=rustdoc-teamGuillaume Gomez-48/+135
[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-27rustdoc: use strategic ThinVec/Box to shrink `clean::ItemKind`Michael Howell-89/+120