about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
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-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.
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-8/+9
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-5/+5
remove in_band_lifetimes from librustdoc r? `@camelid` closes #92368
2021-12-29Rollup merge of #92340 - camelid:search-index-cleanup, r=GuillaumeGomezMatthias Krüger-44/+40
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-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-5/+5
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-28Remove unused parameterNoah Lev-6/+5
2021-12-28Update pulldown-cmark version to 0.9Guillaume Gomez-8/+9
2021-12-27Give clearer names to several search index functionsNoah Lev-12/+24
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-14/+6
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-23/+12
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-3/+3
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-25Remove unneeded call to `collect`Roc Yu-5/+6
2021-12-25Remove `String` allocation in loopRoc Yu-3/+1
2021-12-23Auto merge of #92177 - GuillaumeGomez:pattern-matching-outside-loop, r=camelidbors-6/+8
Move pattern matching outside of the loop Not sure if worth it but it's been bugging me for a while now. r? `@camelid`
2021-12-23Rollup merge of #92146 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-6/+10
Don't emit shared files when scraping examples from dependencies in Rustdoc This PR fixes #91605. The issue is that `Context::init` gets called when scraping dependencies. By default, just calling `init` calls into `write_shared` and `build_index` which register the scraped crate into a list that later gets used for the Rustdoc sidebar. The fix is to ensure that `write_shared` is not called when scraping. r? `@jyn514`
2021-12-22Add some JSDoc comments to rustdoc JSJacob Hoffman-Andrews-30/+170
This follows the Closure Compiler dialect of JSDoc, so we can use it to do some basic type checking. We don't plan to compile with Closure Compiler, just use it to check types. See https://github.com/google/closure-compiler/wiki/ for details.
2021-12-21Move pattern matching outside of the loopGuillaume Gomez-6/+8
2021-12-20Move duplicates removal when generating results instead of when displaying themGuillaume Gomez-11/+13
2021-12-19Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgrbors-11/+2
Rollup of 7 pull requests Successful merges: - #91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts") - #91984 (Remove `in_band_lifetimes` from `rustc_middle`) - #92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets) - #92042 (Enable `#[thread_local]` for all windows-msvc targets) - #92071 (Update example code for Vec::splice to change the length) - #92077 (rustdoc: Remove unused `collapsed` field) - #92081 (rustdoc: Remove unnecessary `need_backline` function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-19Rollup merge of #92077 - jyn514:remove-collapsed, r=GuillaumeGomezMatthias Krüger-11/+2
rustdoc: Remove unused `collapsed` field `render/context` always runs after `run_global_context`, so it was always set to `true`. This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was removed ages ago, and the ability to configure passes is about to be removed. Found while reviewing https://github.com/rust-lang/rust/pull/91305.
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-41/+39
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-19Auto merge of #91871 - camelid:urlpartsbuilder, r=GuillaumeGomezbors-17/+192
rustdoc: Add `UrlPartsBuilder` This is a type for efficiently and easily constructing the part of a URL after the domain: `nightly/core/str/struct.Bytes.html`. It allows simplifying some code and avoiding some allocations in the `href_*` functions. It will also allow making `Cache.paths` et al. use `Symbol` without having to allocate `String`s in the `href_*` functions. `String`s would be necessary otherwise because `Symbol::as_str()` returns `SymbolStr`, whose `Deref<Target = str>` impl requires the `str` to not outlive it. This is the primary motivation for the addition of `UrlPartsBuilder`.
2021-12-18Remove `collapsed` fieldJoshua Nelson-11/+2
`render/context` always runs after `run_global_context`, so it was always set to `true`. This is a holdover from when rustdoc allowed configuring passes, but the `collapse-docs` pass was removed ages ago, and the ability to configure passes is about to be removed.
2021-12-18Rollup merge of #91977 - GuillaumeGomez:unify-search-code, r=jshaMatthias Krüger-110/+102
Clean up search code and unify function returned values This PR is a cleanup: there is no changes in the search results or in the UI. Depending if it was "literal search" or not, it was either returning booleans or integers. It's pretty bad so instead it all returns integers. Another thing I did was to move the add and checks into a `addIntoResults` function to simplify things. Last thing: I removed a loop in the `sortResults` function and moved its code directly into the first loop. All these changes are done to make #90630 much smaller. r? `@jsha`
2021-12-17Auto merge of #91812 - camelid:assoc-const-lazy, r=GuillaumeGomezbors-12/+4
rustdoc: Pretty-print assoc const defaults on-demand This should improve performance, clean up the code, and help pave the way for #83035.
2021-12-16Make loop more clear by renaming variablesGuillaume Gomez-4/+8
2021-12-16Clean up search code and unify function returned valuesGuillaume Gomez-108/+96
2021-12-16Rollup merge of #91958 - jsha:rust-logo, r=GuillaumeGomezMatthias Krüger-18/+14
Apply rust-logo class only on default logo Fixes #91653. ![image](https://user-images.githubusercontent.com/220205/146138145-a7a62ea6-3205-4bc7-8460-e985284d93ea.png) Demo: https://rustdoc.crud.net/jsha/hashes/sha2/ r? ``@GuillaumeGomez``
2021-12-15Apply rust-logo class only on default logoJacob Hoffman-Andrews-18/+14
Also replace ' with " in rustdoc template
2021-12-15Auto merge of #91962 - matthiaskrgr:rollup-2g082jw, r=matthiaskrgrbors-3/+3
Rollup of 7 pull requests Successful merges: - #91880 (fix clippy::single_char_pattern perf findings) - #91885 (Remove `in_band_lifetimes` from `rustc_codegen_ssa`) - #91898 (Make `TyS::is_suggestable` check for non-suggestable types structually) - #91915 (Add another regression test for unnormalized fn args with Self) - #91916 (Fix a bunch of typos) - #91918 (Constify `bool::then{,_some}`) - #91920 (Use `tcx.def_path_hash` in `ExistentialPredicate.stable_cmp`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-15Rollup merge of #91880 - matthiaskrgr:clippy_perf_dec, r=jyn514Matthias Krüger-3/+3
fix clippy::single_char_pattern perf findings
2021-12-15Rollup merge of #91905 - GuillaumeGomez:source-code-page-sidebar, r=jshaMatthias Krüger-2/+10
Fix source code page sidebar on mobile Current broken behaviour: https://user-images.githubusercontent.com/3050060/145984316-35c82353-5bab-4dc6-9ac6-63ea7e5c27d8.mp4 Fixed: https://user-images.githubusercontent.com/3050060/145984329-8be1127b-d707-424d-ac3c-c1fb3c48a093.mp4 r? `@jsha`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-24/+24
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-17/+15
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14fix clippy::single_char_pattern perf findingsMatthias Krüger-3/+3
2021-12-14Fix sidebar in source code pageGuillaume Gomez-2/+10
2021-12-13rustdoc: Add `UrlPartsBuilder`Noah Lev-17/+192
This is a type for efficiently and easily constructing the part of a URL after the domain: `nightly/core/str/struct.Bytes.html`. It allows simplifying some code and avoiding some allocations in the `href_*` functions. It will also allow making `Cache.paths` et al. use `Symbol` without having to allocate `String`s in the `href_*` functions. `String`s would be necessary otherwise because `Symbol::as_str()` returns `SymbolStr`, whose `Deref<Target = str>` impl requires the `str` to not outlive it. This is the primary motivation for the addition of `UrlPartsBuilder`.
2021-12-13Rollup merge of #91699 - jsha:webkit-appearance-search-input, r=GuillaumeGomezMatthias Krüger-0/+4
Add `-webkit-appearance: none` to search input This fixes an issue when displaying on iPad, where the search box had no borders. r? ``@GuillaumeGomez`` Demo https://rustdoc.crud.net/jsha/webkit-appearance-search-input/std/string/struct.String.html
2021-12-12Add -webkit-appearance: none to search inputJacob Hoffman-Andrews-0/+4
This fixes an issue when displaying on iPad, where the search box had no borders.
2021-12-11rustdoc: Remove unused `_default` parameterNoah Lev-12/+4
It can always be re-added later if we decide to display associated const default values.
2021-12-11rustdoc: Pretty-print assoc const defaults on-demandNoah Lev-1/+1
This should improve performance, clean up the code, and help pave the way for #83035.