about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2024-08-21Auto merge of #129331 - matthiaskrgr:rollup-rxv463w, r=matthiaskrgrbors-24/+20
Rollup of 9 pull requests Successful merges: - #128662 (Lint on tail expr drop order change in Edition 2024) - #128932 (skip updating when external binding is existed) - #129270 (Don't consider locals to shadow inner items' generics) - #129277 (Update annotate-snippets to 0.11) - #129294 (Stabilize `iter::repeat_n`) - #129308 (fix: simple typo in compiler directory) - #129309 (ctfe: make CompileTimeInterpCx type alias public) - #129314 (fix a broken link in `mir/mod.rs`) - #129318 (Remove unneeded conversion to `DefId` for `ExtraInfo`) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-20rustdoc: add test case for modnav position when TOC is offMichael Howell-11/+7
2024-08-20rustdoc: consistentify `#TOC` and `#ModNav` to lowercaseMichael Howell-8/+9
2024-08-20rustdoc: show code spans as `<code>` in TOCMichael Howell-11/+69
2024-08-20rustdoc: add separate section for module itemsMichael Howell-3/+14
2024-08-20rustdoc: add separate section for module itemsMichael Howell-11/+35
2024-08-20Add configuration options to hide TOC or module navigationMichael Howell-20/+74
2024-08-20Add Top TOC support to rustdocMichael Howell-121/+201
This commit adds the headers for the top level documentation to rustdoc's existing table of contents, along with associated items. It only show two levels of headers. Going further would require the sidebar to be wider, and that seems unnecessary (the crates that have manually-built TOCs usually don't need deeply nested headers).
2024-08-20Auto merge of #128252 - EtomicBomb:pre-rfc, r=notriddlebors-683/+1551
modularize rustdoc's write_shared Refactor src/librustdoc/html/render/write_shared.rs to reduce code duplication, adding unit tests * Extract + unit test code for sorting and rendering JSON, which is duplicated 9 times in the current impl * Extract + unit test code for encoding JSON as single quoted strings, which is duplicated twice in the current impl * Unit tests for cross-crate information file formats * Generic interface to add new kinds of cross-crate information files in the future * Intended to match current behavior exactly, except for a merge info comment it adds to the bottom of cci files * This PR is intended to reduce the review burden from my [mergeable rustdoc rfc](https://github.com/rust-lang/rfcs/pull/3662) implementation PR, which is a [small commit based on this branch](https://github.com/EtomicBomb/rust/tree/rfc). This code is agnostic to the RFC and does not include any of the flags discussed there, but cleanly enables the addition of these flags in the future because it is more modular
2024-08-20Remove unneeded conversion to `DefId` for `ExtraInfo`Guillaume Gomez-24/+20
2024-08-19rustdoc: animate the `:target` highlightMichael Howell-0/+13
This approach is, roughly, based on how Discourse does it. It came up while discussing some other possible sidebar changes, as a design that made rapid scanning easier while avoiding the inherent trade-offs in summarizing.
2024-08-13Unify naming of `DocTest`Guillaume Gomez-2/+2
2024-08-13Improve code readabilityGuillaume Gomez-1/+1
2024-08-13Rename `DocTest` into `DocTestBuilder`Guillaume Gomez-1/+1
2024-08-13Correctly handle doctests with invalid ASTGuillaume Gomez-1/+1
2024-08-13Add new doc codeblock `standalone` attributeGuillaume Gomez-0/+6
2024-08-13Split standalone and mergeable doctestsGuillaume Gomez-2/+2
2024-08-13Split doctests between standalone and mergeable onesGuillaume Gomez-2/+2
2024-08-13Add `DocTest` typeGuillaume Gomez-2/+3
2024-08-12Rollup merge of #128394 - GuillaumeGomez:run-button, r=t-rustdocGuillaume Gomez-44/+29
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-10Rollup merge of #128923 - GuillaumeGomez:negative-impls-items, r=fmeaseGuillaume Gomez-19/+23
[rustdoc] Stop showing impl items for negative impls Fixes https://github.com/rust-lang/rust/issues/128799. As discussed with `@fmease,` they have a broader patch in progress, so this (small) PR will at least allow for them to have a regression test. :) r? `@fmease`
2024-08-10Stop showing impl items for negative implsGuillaume Gomez-19/+23
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-07rename sortedjson -> orderedjsonEtomicBomb-192/+227
2024-08-07added unit tests for write_sharedEtomicBomb-51/+257
2024-08-07move sorted_template and sorted_json testsEtomicBomb-271/+270
2024-08-07add blank line, remove extraneous commentEtomicBomb-1/+0
2024-08-07initial implementation of mergable rustdoc cciEtomicBomb-682/+1315
2024-08-06rustdoc-search: account for numeric disambiguators on implsMichael Howell-6/+12
Fixes #128676
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-23/+15
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-3/+13
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-8/+8
`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 #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-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-01rustdoc: Remove dead opaque_tys rendering logicAlona Enraght-Moony-11/+0
2024-08-01rustdoc: Remove OpaqueTyAlona Enraght-Moony-33/+0
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/+106
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.