summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2022-01-20Fix style for rust logoGuillaume Gomez-3/+3
2022-01-20rustdoc: fix intra-link for generic trait implsMahdi Dibaiee-1/+12
2022-01-08Auto merge of #91305 - camelid:rm-cond, r=GuillaumeGomezbors-3/+0
rustdoc: Remove apparently unnecessary conditional in `doc_value` I need to remove this conditional for #91072, but while it seems unnecessary, we are not certain. So, the plan is to first remove the conditional and see if any regressions pop up before doing the refactor. This way, it will be easier to revert if there are subtle regressions. r? `@jyn514`
2022-01-07Rollup merge of #92610 - GuillaumeGomez:css-class-instead-of-inline-style, ↵Eric Huss-2/+6
r=jsha Create CSS class instead of using inline style for search results I saw this change in the update you proposed in https://github.com/rust-lang/rust/pull/92404. :) r? ``@jsha``
2022-01-06Create CSS class instead of using inline style for search resultsGuillaume Gomez-2/+6
2022-01-06Rollup merge of #92443 - mdibaiee:90703/resolve-traits-of-primitive-types, ↵Matthias Krüger-21/+71
r=Manishearth Rustdoc: resolve associated traits for non-generic primitive types Fixes #90703 This seems to work: <img width="457" alt="image" src="https://user-images.githubusercontent.com/2807772/147774059-9556ff96-4519-409e-8ed0-c33ecc436171.png"> I'm just afraid I might have missed some cases / broken previous functionality. I also have not written tests yet, I will have to take a look to see where tests are and how they are structured, but any help there is also appreciated.
2022-01-06Rollup merge of #92404 - GuillaumeGomez:src-font-size, r=jshaMatthias Krüger-13/+7
Fix font size for [src] links in headers Fixes #90384. cc `@jsha` r? `@camelid`
2022-01-06Rollup merge of #92349 - avitex:fix-rustdoc-private-doc-tests, r=GuillaumeGomezMatthias Krüger-1/+1
Fix rustdoc::private_doc_tests lint for public re-exported items Closes #72081 This involves changing the lint to check the access level is exported, rather than public. The [exported access level](https://github.com/rust-lang/rust/blob/e91ad5fc62bdee4a29c18baa5fad2ca42fc91bf4/compiler/rustc_middle/src/middle/privacy.rs#L24) accounts for public items and items accessible to other crates with the help of `pub use` re-exports. The pattern of re-exporting public items from a private module is usage seen in a number of popular crates.
2022-01-06Rollup merge of #92058 - jsha:run-on-hover, r=GuillaumeGomezMatthias Krüger-1/+4
Make Run button visible on hover This slightly reduces the noisiness of doc pages, making them easier to read. Demo: https://rustdoc.crud.net/jsha/run-on-hover/std/string/struct.String.html [Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/.22Run.22.20button.20visible.20on.20hover). Part of #59845
2022-01-05Simplify :target CSS selectorGuillaume Gomez-12/+3
2022-01-05Fix font size for [src] links in headersGuillaume Gomez-1/+4
2022-01-05Make Run button visible on hoverJacob Hoffman-Andrews-1/+4
This slightly reduces the noisiness of doc pages, making them easier to read.
2022-01-05Rollup merge of #92448 - jsha:font-size-access, r=GuillaumeGomezMatthias Krüger-53/+58
Set font size proportional to user's font size According to MDN (https://developer.mozilla.org/en-US/docs/Web/CSS/font-size), > To maximize accessibility, it is generally best to use values that are relative to the user's default font size. > Defining font sizes in px is not accessible, because the user cannot change the font size in some browsers. Note that changing font size (in browser or OS settings) is distinct from the zoom functionality triggered with Ctrl/Cmd-+. Zoom functionality increases the size of everything on the page, effectively applying a multiplier to all pixel sizes. Font size changes apply to just text. For relative font sizes, we could use `em`, as we do in several places already. However that has a problem of "compounding" (see MDN article for details). The compounding problem is nicely solved by `rem`, which make font sizes relative to the root element, not the parent element. Since we were using a hodge-podge of pixel sizes, em, rem, and percentage sizes before, this change switches everything to rem, while keeping the same size relative to our old default of 16px. 16px is still the default on most browsers, for users that haven't set a larger or smaller font size. Part of #59845. Note: this will conflict with #92404. We should merge that first (once it's done) and I'll resolve the merge conflicts. r? `@GuillaumeGomez` Demo: https://rustdoc.crud.net/jsha/font-size-access/std/string/struct.String.html
2022-01-05Rollup merge of #92188 - vacuus:nested-attributes-ext, r=jyn514Matthias Krüger-10/+15
rustdoc: Clean up NestedAttributesExt trait/implementation
2022-01-05Remove unsupported types in primitive_to_ty conversion, add FIXME noteMahdi Dibaiee-8/+3
2022-01-05Rustdoc: resolve associated traits for primitive typesMahdi Dibaiee-21/+76
Fixes #90703
2022-01-04Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwUMatthias Krüger-11/+17
Allow `_` as the length of array types and repeat expressions r? `@BoxyUwU` cc `@varkor`
2022-01-03Auto merge of #92395 - Kobzol:rustdoc-bindings-thin-vec, r=camelidbors-7/+9
Rustdoc: use ThinVec for GenericArgs bindings The bindings are almost always empty. This reduces the size of `PathSegment` and `GenericArgs` by about one fourth.
2022-01-02Set font size proportional to user's font sizeJacob Hoffman-Andrews-53/+58
According to MDN (https://developer.mozilla.org/en-US/docs/Web/CSS/font-size), > To maximize accessibility, it is generally best to use values that > are relative to the user's default font size. > Defining font sizes in px is not accessible, because the user cannot > change the font size in some browsers. Note that changing font size (in browser or OS settings) is distinct from the zoom functionality triggered with Ctrl/Cmd-+. Zoom functionality increases the size of everything on the page, effectively applying a multiplier to all pixel sizes. Font size changes apply to just text. For relative font sizes, we could use `em`, as we do in several places already. However that has a problem of "compounding" (see MDN article for details). The compounding problem is nicely solved by `rem`, which make font sizes relative to the root element, not the parent element. Since we were using a hodge-podge of pixel sizes, em, rem, and percentage sizes before, this change switching everything to rem, while keeping the same size relative to our old default of 16px. 16px is still the default on most browsers, for users that haven't set a larger or smaller font size.
2022-01-01Rustdoc: use ThinVec for GenericArgs bindingsJakub Beránek-7/+9
2021-12-31Rollup merge of #92440 - GuillaumeGomez:fix-mobile-toggles, r=jshaMatthias Krüger-0/+10
Fix mobile toggles position Before: ![Screenshot from 2021-12-29 18-53-33](https://user-images.githubusercontent.com/3050060/147764842-082f6fa2-b631-4c47-ba34-ced76fe8494f.png) After: ![Screenshot from 2021-12-29 18-52-48](https://user-images.githubusercontent.com/3050060/147764853-13046330-2442-4fad-b26a-84c167711b54.png) r? `@jsha`
2021-12-31Rollup merge of #91480 - jsha:fewer-colors, r=GuillaumeGomezMatthias Krüger-61/+75
rustdoc: use smaller number of colors to distinguish items This reduces visual distractions when reading method signatures. As discussed in https://github.com/rust-lang/rust/issues/59845#issuecomment-974757191, this categorizes items into one of six colors (down from thirteen): - method, function (ochre `#AD7C37`) - trait, trait alias (dark slate blue `#6E4FC9`) - enum, struct, type alias, union, primitive (maroon `#AD378A`) - static, module, keyword, associated type, foreign type (steel blue `#3873AD`) - macro (green `#068000`) - generic params, self, Self (unmarked black `#000000`) I slightly tweaked the actual color values so they'd have the same lightness (previously the trait color stood out much more than the others). And I made the color for links in general consistently use steel blue (previously there was a slightly different color for "search-failed"). The ayu and dark themes have been updated according to the same logic. I haven't changed any of the color values in those themes, just their assignment to types. Demo: https://rustdoc.crud.net/jsha/fewer-colors/std/string/struct.String.html https://rustdoc.crud.net/jsha/fewer-colors/std/vec/struct.Vec.html https://rustdoc.crud.net/jsha/fewer-colors/std/io/trait.Read.html https://rustdoc.crud.net/jsha/fewer-colors/std/iter/trait.Iterator.html
2021-12-31Auto merge of #92252 - GuillaumeGomez:update-pulldown, r=camelid,xFrednetbors-9/+10
Update pulldown-cmark version to 0.9 Fixes https://github.com/rust-lang/rust/issues/92206. r? `@camelid`
2021-12-30Fix display of toggles on mobileGuillaume Gomez-0/+10
2021-12-30Auto merge of #92377 - compiler-errors:rustdoc-lifetimes, r=camelid,jyn514bors-20/+19
remove in_band_lifetimes from librustdoc r? `@camelid` closes #92368
2021-12-29Auto merge of #92244 - petrochenkov:alltraits, r=cjgillotbors-6/+4
rustc_metadata: Encode list of all crate's traits into metadata While working on https://github.com/rust-lang/rust/pull/88679 I noticed that rustdoc is casually doing something quite expensive, something that is used only for error reporting in rustc - collecting all traits from all crates in the dependency tree. This PR trades some minor extra time spent by metadata encoder in rustc for major gains for rustdoc (and for rustc runs with errors, which execute the `all_traits` query for better diagnostics).
2021-12-29Rollup merge of #92340 - camelid:search-index-cleanup, r=GuillaumeGomezMatthias Krüger-50/+54
rustdoc: Start cleaning up search index generation I'm trying to simplify and clean up the code, partly to make #90779 easier. r? `@GuillaumeGomez`
2021-12-29Rollup merge of #92075 - jyn514:resolve-cleanup, r=camelidMatthias Krüger-16/+25
rustdoc: Only special case struct fields for intra-doc links, not enum variants Variants are already handled by `resolve_str_path_error`, rustdoc doesn't need to consider them separately. Thanks `@camelid` for catching this! Eventually I'd like to fix the "combine this with `variant_field`" comment but that needs `resolve_field` to take a `ty_res` parameter to avoid it being super hacky (cc https://github.com/rust-lang/rust/issues/83761#issuecomment-813026026). r? `@camelid`
2021-12-29Auto merge of #92283 - vacuus:print-generic-bounds, r=camelid,GuillaumeGomezbors-3/+1
rustdoc: Remove `String` allocation in iteration in `print_generic_bounds` (I realized only after making the commit that maybe I shouldn't refer to iteration as looping, but it's close enough) The string representation of a `clean::GenericBound` instance (evaluated [here](https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/format.rs#L397)) is deterministic for a given `self` (the instance), `cx` and `f`, and since `cx` and `f` are constant (as far as I can tell) for a given invocation of `print_generic_bounds`, `self` is the determining factor. Therefore, using the data in `self` shouldn't differ in effect from using its string representation. Given the totality of the function calls needed to evaluate the string representation as well as the actual allocation, at the very least, this shouldn't negatively affect performance.
2021-12-28remove in_band_lifetimes from librustdocMichael Goulet-20/+19
2021-12-28Auto merge of #92269 - vacuus:clean-generics-print, r=camelidbors-5/+6
rustdoc: Remove `collect` call in `clean::Generics::print`
2021-12-28Add regression test for #59502Noah Lev-0/+2
This issue was fixed using a hacky recursion "fuel" argument, but the issue was never minimized nor was a regression test added. The underlying bug is still unfixed, so this test should help with fixing it and removing the `recurse` hack.
2021-12-28Explain why struct fields are handled by assoc. item codeNoah Lev-0/+12
2021-12-28Remove unused parameterNoah Lev-6/+5
2021-12-28Only special case struct fields for intra-doc links, not enum variantsJoshua Nelson-16/+13
Variants are already handled by `resolve_str_path_error`, rustdoc doesn't need to consider them separately.
2021-12-28Update pulldown-cmark version to 0.9Guillaume Gomez-9/+10
2021-12-28rustc_metadata: Encode list of all crate's traits into metadataVadim Petrochenkov-6/+4
2021-12-28Fix rustdoc::private_doc_tests lint for public re-exported itemsavitex-1/+1
This involves changing the lint to check the access level is exported, rather than public. The exported access level accounts for public items and items accessible to other crates with the help of `pub use` re-exports. The pattern of re-exporting public items from a private module is usage seen in a number of popular crates.
2021-12-27Give clearer names to several search index functionsNoah Lev-14/+26
2021-12-27Coalesce two arguments as `&Function`Noah Lev-6/+8
2021-12-27Make `search_index` functions private where possibleNoah Lev-2/+2
Now the only two crate-public items are `build_index` and `get_index_search_type` (because for some reason the latter is also used in `formats::cache`).
2021-12-27Move `ExternalLocation` to `clean::types`Noah Lev-19/+19
It was previously defined in `render::search_index` but wasn't used at all there. `clean::types` seems like a better fit since that's where `ExternalCrate` is defined.
2021-12-27rustdoc: Remove some unnecessary `cache` parametersNoah Lev-24/+13
Based on https://github.com/rust-lang/rust/pull/80883#issuecomment-774437832. The `tcx` parameters do seem to be used though, so I only removed the `cache` parameters.
2021-12-27Rename `rustdoc::html::render::cache` to `search_index`Noah Lev-6/+6
The old name wasn't very clear, while the new one makes it clear that this is the code responsible for creating the search index.
2021-12-27intra-doc: Use an enum to represent URL fragmentsNoah Lev-78/+113
This is a step in the direction of computing the links more lazily, which I think will simplify the implementation of intra-doc links. This will also make it easier to eventually use the actual `Res` for associated items, enum variants, and fields, rather than their HTML page's `Res`.
2021-12-27Remove needless `return`Noah Lev-1/+1
2021-12-25Remove unneeded call to `collect`Roc Yu-5/+6
2021-12-25Remove `String` allocation in loopRoc Yu-3/+1
2021-12-25Auto merge of #92262 - notriddle:notriddle/unused-hash, r=jyn514bors-11/+2
rustdoc: remove unused Hash impl
2021-12-25Auto merge of #92227 - Kobzol:rustdoc-doc-hidden, r=jyn514bors-16/+7
Rustdoc: use `is_doc_hidden` method on more places While profiling `rustdoc`, I noticed that finding out if some item is marked with `#[doc(hidden)]` is relatively hot, so I tried to optimize it. I noticed that there is already a method called `is_doc_hidden` on `TyCtxt`, but it wasn't used much, so I replaced the manual calls to `attrs(...).has_word(...)` with this method. Just by doing that, perf. was improved locally, although I'm not sure if the semantics of the previous calls and this method are the same? As another step, I tried to querify `is_doc_hidden`, but I didn't include that here until we see the perf. results from the first commit and until I find whether this change is OK at all :) Can I ask for a perf. run? Thanks. r? `@jyn514`