about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2023-09-15rustdoc: merge theme css into rustdoc.cssMichael Howell-420/+641
Based on https://github.com/rust-lang/rust/pull/115812#issuecomment-1717960119 Having them in separate files used to make more sense, before the migration to CSS variables made the theme files as small as they are nowadays. This is already how docs.rs and mdBook do it.
2023-09-13Rollup merge of #115812 - GuillaumeGomez:merge-settings-into-rustdoc-css, ↵Matthias Krüger-76/+64
r=notriddle Merge settings.css into rustdoc.css There aren't that many CSS rules in `settings.css`, however quite some code is needed around it, making it more costly than useful. I think it's better to merge into `rustdoc.css` to simplify this. r? `@notriddle`
2023-09-13Merge settings.css into rustdoc.cssGuillaume Gomez-76/+64
2023-09-11Add missing ID into the ID mapGuillaume Gomez-0/+1
2023-09-11Add missing "Aliased type" title in the sidebarGuillaume Gomez-0/+1
2023-09-10Auto merge of #115682 - notriddle:notriddle/impl-sidebar, r=GuillaumeGomezbors-48/+66
rustdoc: add impl items from aliased type into sidebar Follow-up of https://github.com/rust-lang/rust/pull/115201.
2023-09-10rustdoc: filter before storing in vecMichael Howell-4/+10
2023-09-09rustdoc: factor all-impls-for-item out into its own methodMichael Howell-78/+55
2023-09-09rustdoc-search: fix bugs when unboxing and reordering combineMichael Howell-235/+275
2023-09-09Auto merge of #115669 - GuillaumeGomez:js-anonymous-functions, r=notriddlebors-18/+18
rustdoc: Change syntax for anonymous functions set in JS This function is not very useful in itself but it slightly reduces the JS size so it's always that I suppose... No changes in behaviour. r? `@notriddle`
2023-09-08rustdoc: add impl items from aliased type into sidebarMichael Howell-5/+40
2023-09-08Rollup merge of #115201 - notriddle:notriddle/type-alias-impl-list, ↵Guillaume Gomez-4/+43
r=GuillaumeGomez rustdoc: list matching impls on type aliases Fixes https://github.com/rust-lang/rust/issues/32077 Fixes #99952 Remake of https://github.com/rust-lang/rust/pull/112429 Partially reverts https://github.com/rust-lang/rust/pull/112543, but keeps the test case. This version of the PR avoids the infinite loop by structurally matching types instead of using full unification. This version does not support type alias trait bounds, but the compiler does not enforce those anyway (https://github.com/rust-lang/rust/issues/21903). r? `@GuillaumeGomez` CC `@lcnr`
2023-09-08Change syntax for anonymous functions setGuillaume Gomez-18/+18
2023-09-08Rollup merge of #115655 - notriddle:notriddle/rustdoc-fe-cleanup, ↵Matthias Krüger-3/+1
r=GuillaumeGomez rustdoc: remove unused ID `mainThemeStyle` This was added in https://github.com/rust-lang/rust/pull/47620 and used to build the URL of the theme stylesheets. It isn't used any more, because https://github.com/rust-lang/rust/pull/101702 changed it so that the URL was supplied in a `<meta>` tag, which also provides the hashes of the files.
2023-09-08Rollup merge of #115604 - GuillaumeGomez:private-fields-tuple-struct, ↵Matthias Krüger-14/+30
r=notriddle rustdoc: Render private fields in tuple struct as `/* private fields */` Reopening of https://github.com/rust-lang/rust/pull/110552. All that was missing was a test for the different cases so I added it into the second commit. Description from the original PR: > I've gotten some feedback that the current rustdoc rendering of... > > ``` > struct HasPrivateFields(_); > ``` > > ...is confusing, and I agree with that feedback, especially compared to the field struct case: > > ``` > struct HasPrivateFields { /* private fields */ } > ``` > > So this PR makes it so that when all of the fields of a tuple variant are private, just render it with the `/* private fields */` comment. We can't *always* render it like that, for example when there's a mix of private and public fields. cc ````@jsha```` r? ````@notriddle````
2023-09-07rustdoc: remove unused ID `mainThemeStyle`Michael Howell-3/+1
This was added in 003b2bc1c65251ec2fc80b78ed91c43fb35402ec and used to build the URL of the theme stylesheets. It isn't used any more, because f9e1f6ffdf03ec33cb29e20c88fc7bcc938c7f42 changed it so that the URL was supplied in a `<meta>` tag, which also provides the hashes of the files.
2023-09-07Auto merge of #114855 - Urgau:rustdoc-typedef-inner-variants, r=GuillaumeGomezbors-133/+290
rustdoc: show inner enum and struct in type definition for concrete type This PR implements the [Display enum variants for generic enum in type def page](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Display.20enum.20variants.20for.20generic.20enum.20in.20type.20def.20page) #rustdoc/zulip proposal. This proposal comes from looking at [`TyKind`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/sty/type.TyKind.html) typedef from the compiler. On that page, the documentation is able to show the layout for each variant, but not the variants themselves. This proposal suggests showing the fields and variants for those "concrete type". This would mean that instead of having many unresolved generics, like in `IrTyKind`: ```rust Array(I::Ty, I::Const), Slice(I::Ty), RawPtr(I::TypeAndMut), Ref(I::Region, I::Ty, I::Mutability), FnDef(I::DefId, I::GenericArgsRef), ``` those would be resolved with direct links to the proper types in the `TyKind` typedef page: ```rust Array(Ty<'tcx>, Const<'tcx>), Slice(Ty<'tcx>), RawPtr(TypeAndMut<'tcx>), Ref(Region<'tcx>, Ty<'tcx>, Mutability<'tcx>), FnDef(DefId<'tcx>, GenericArgsRef<'tcx>), ``` Saving both time and confusion. ----- <details> <summary>Old description</summary> I've chosen to add the enums and structs under the "Show Aliased Type" details, as well as showing the variants and fields under the usual "Variants" and "Fields" sections. ~~*under new the `Inner Variants` and `Inner Fields` sections (except for their names, they are identical to the one found in the enum, struct and union pages). Those sections are complementary and do not replace anything else.*~~ This PR proposes the following condition for showing the aliased type (basically, has the aliased type some generics that are all of them resolved): - the typedef does NOT have any generics (modulo lifetimes) - AND the aliased type has some generics </details> ### Examples ```rust pub enum IrTyKind<'a, I: Interner> { /// Doc comment for AdtKind AdtKind(&'a I::Adt), /// and another one for TyKind TyKind(I::Adt, I::Ty), // no comment StructKind { a: I::Adt, }, } pub type TyKind<'a> = IrTyKind<'a, TyCtxt>; ``` ![TyKind](https://github.com/rust-lang/rust/assets/3616612/13307679-6d48-40d6-ad50-6db0b7f36ac7) <details> <summary>Old</summary> ![image](https://github.com/rust-lang/rust/assets/3616612/4147c049-d056-42d4-8a01-d43ebe747308) ![TyKind](https://user-images.githubusercontent.com/3616612/260988247-34831aa9-470d-4286-ad9f-3e8002153a92.png) ![TyKind](https://github.com/rust-lang/rust/assets/3616612/62381bb3-fa0f-4b05-926d-77759cf9115a) </details> ```rust pub struct One<T> { pub val: T, #[doc(hidden)] pub inner_tag: u64, __hidden: T, } /// `One` with `u64` as payload pub type OneU64 = One<u64>; ``` ![OneU64](https://github.com/rust-lang/rust/assets/3616612/d551b474-ce88-4f8c-bc94-5c88aba51424) <details> <summary>Old</summary> ![image](https://github.com/rust-lang/rust/assets/3616612/1a3f53c0-17bf-4aa7-894d-3fedc15b33da) ![OneU64](https://github.com/rust-lang/rust/assets/3616612/7b124a5b-e287-4efb-b9ca-fdcd1cdeeba8) ![OneU64](https://github.com/rust-lang/rust/assets/3616612/ddd962be-4f76-4ecd-81bd-531f3dd23832) </details> r? `@GuillaumeGomez`
2023-09-06Render missing fields in tuple struct/enum as /* private fields */Michael Goulet-14/+30
2023-09-05Auto merge of #115507 - cjgillot:relative-source-file, r=oli-obkbors-1/+1
Use relative positions inside a SourceFile. This allows to remove the normalization of start positions for hashing, and simplify allocation of global address space. cc `@Zoxc`
2023-09-03rustdoc: fix test case for generics that look like namesMichael Howell-1/+2
2023-09-03rustdoc: bug fix for `-> option<t>`Michael Howell-1/+5
2023-09-03rustdoc-search: add support for type parametersMichael Howell-286/+472
When writing a type-driven search query in rustdoc, specifically one with more than one query element, non-existent types become generic parameters instead of auto-correcting (which is currently only done for single-element queries) or giving no result. You can also force a generic type parameter by writing `generic:T` (and can force it to not use a generic type parameter with something like `struct:T` or whatever, though if this happens it means the thing you're looking for doesn't exist and will give you no results). There is no syntax provided for specifying type constraints for generic type parameters. When you have a generic type parameter in a search query, it will only match up with generic type parameters in the actual function, not concrete types that match, not concrete types that implement a trait. It also strictly matches based on when they're the same or different, so `option<T>, option<U> -> option<U>` matches `Option::and`, but not `Option::or`. Similarly, `option<T>, option<T> -> option<T>`` matches `Option::or`, but not `Option::and`.
2023-09-03rustdoc-search: `null`, not `-1`, for missing idMichael Howell-14/+14
This allows us to use negative numbers for others purposes.
2023-09-03Rollup merge of #115490 - pitaj:rustdoc-searchjs-comment, r=GuillaumeGomezGuillaume Gomez-8/+17
rustdoc: update comment in search.js for #107629 Addressing https://github.com/rust-lang/rust/pull/107629#issuecomment-1693460106 r? `@jsha`
2023-09-03Use relative positions inside a SourceFile.Camille GILLOT-1/+1
2023-09-02rustdoc: update comment in search.js for #107629Peter Jaszkowiak-8/+17
2023-09-02Correctly handle paths from foreign itemsGuillaume Gomez-11/+46
2023-09-01Merge all loops into one when generating search indexGuillaume Gomez-92/+65
2023-09-01[rustdoc] Fix path in type-based searchGuillaume Gomez-36/+139
2023-08-31Improve `search.js` codeGuillaume Gomez-17/+13
2023-08-28rustdoc: always print type alias inner type (with it's where clauses)Urgau-5/+14
2023-08-27Unify CSS color formats a bit moreGuillaume Gomez-14/+14
2023-08-26Add note about lazy_type_aliasMichael Howell-2/+2
Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2023-08-26rustdoc: remove details for type alias inner type and fix sidebarUrgau-94/+77
2023-08-26rustdoc: bind typedef inner type items to the folding systemUrgau-13/+20
This let's us handle a multitude of things for free: - #[doc(hidden)] - private fields/variants - --document-private-items - --document-hidden-items And correct in the process the determination of "has stripped items" by doing the same logic done by other ones.
2023-08-26rustdoc: show inner enum and struct in type definition for concrete typeUrgau-0/+94
2023-08-24rustdoc: list matching impls on type aliasesMichael Howell-4/+43
Remake of "List matching impls on type aliases" * 4b1d13d9841c815915433ca2a3088a8e3e97ad96 * 6f552c800b38b3e71c5e33a295e8b490d2018c71 * 2ce7cd906bde70d8cbd9b07b31c6a7bf1131c345 Partially reverts "Fix infinite loop when retrieving impls for type alias", but keeps the test case. This version of the PR avoids the infinite loop by structurally matching types instead of using full unification. This version does not support type alias trait bounds, but the compiler does not enforce those anyway (https://github.com/rust-lang/rust/issues/21903).
2023-08-24rustdoc: extract logic for printing enum fields and struct variantsUrgau-131/+195
2023-08-24Auto merge of #115078 - camelid:tydef-to-alias, r=aDotInTheVoid,GuillaumeGomezbors-22/+22
rustdoc: Rename typedef to type alias This matches the name used by the [Rust Reference][1], which is also what people usually call these items. [1]: https://doc.rust-lang.org/reference/items/type-aliases.html r? `@GuillaumeGomez`
2023-08-23Rollup merge of #115135 - GuillaumeGomez:no-html-source-flag, r=notriddleGuillaume Gomez-1/+2
Rustdoc: Add unstable --no-html-source flag Fixes https://github.com/rust-lang/rust/issues/115060. This is the equivalent of `#![doc(no_html_source)]` but on the command-line. It disables the generation of the source pages (and of the links pointing to them as well). The motivation behind this is to enable to reduce documentation size when generating it in some locations without enforcing this to end users or adding a new feature to enable/disable the crate attribute. r? `@notriddle`
2023-08-23Add unstable `--no-html-source` rustdoc flagGuillaume Gomez-1/+2
2023-08-21rustdoc-json: Rename typedef to type aliasNoah Lev-5/+5
2023-08-21rustdoc: Rename `clean` items from typedef to type aliasNoah Lev-18/+18
2023-08-21rustdoc: Rename "Type Definition" to "Type Alias"Noah Lev-3/+3
This matches the name used by the Rust Reference [1], which is also what people usually call these items. [1]: https://doc.rust-lang.org/reference/items/type-aliases.html
2023-08-21Auto merge of #106561 - GuillaumeGomez:warning-block, r=rustdocbors-3/+26
Add warning block support in rustdoc Fixes https://github.com/rust-lang/rust/issues/79710. You can test it [here](https://rustdoc.crud.net/imperio/warning-block/foo/struct.Foo.html). It currently looks like this: ![image](https://user-images.githubusercontent.com/3050060/211413494-e1cf04e4-c081-4a9d-97db-27329405cfa7.png) So a few things to note: * Since it's a new add and it's changing the UI, we'll need to go through an FCP. * Does the UI looks good? * Is the way picked to add a warning block ok for everyone? The discussion on the issue seemed to be in favour of this solution but it doesn't hurt to double-check. cc `@rust-lang/rustdoc`
2023-08-18narrow down the lint trigger constraintKyle Lin-9/+26
2023-08-18Fix resolution cachingKyle Lin-0/+1
2023-08-18rework link parsing loopKyle Lin-24/+65
2023-08-16Rollup merge of #114822 - GuillaumeGomez:code-readability-improvement, ↵Matthias Krüger-175/+182
r=notriddle Improve code readability by moving fmt args directly into the string There are some of occurrences where I also transformed `write!(f, "{}", x)` into `f.write_str(x.as_str())`. r? `@notriddle`
2023-08-16Rollup merge of #113115 - tshepang:patch-5, r=est31Matthias Krüger-1/+1
we are migrating to askama see https://github.com/rust-lang/rust/issues/108868