about summary refs log tree commit diff
path: root/src/librustdoc/html/static
AgeCommit message (Collapse)AuthorLines
2021-04-13Further consolidate search-related vars and funcsJacob Hoffman-Andrews-76/+61
2021-04-13Consolidate search-related vars and functions.Jacob Hoffman-Andrews-175/+167
This allows sharing across main.js and search.js without exporting too many symbols into the global namespace.
2021-04-12Move search JS into search-index.jsJacob Hoffman-Andrews-1521/+1528
Export a few variables and functions into the global scope because they are needed both by main.js and search-index.js.
2021-04-12+ignore-tidy-filelengthManish Goregaokar-1/+2
2021-04-12Move color to themesManish Goregaokar-5/+9
2021-04-12Add css classesManish Goregaokar-10/+10
2021-04-12Improve CSS for "hide contents, not items"Jacob Hoffman-Andrews-80/+68
Introduce a first use of the `<details>` and `<summary>` tags as replacements for the JS-built toggles. I think this has the potential to replace all the JS toggles and generally clean up the JS, CSS, and HTML. Split rendering of attributes into two cases: in the case where they are rendered as descendents of a `<pre>` tag, where they use indent spaces and newlines for formatting, matching their surrounding markup. In the case where they are rendered as descendants of a `<code>` tag, they are rendered as `<div>`. This let me clean up some fragile CSS that was adjusting the margin-left of attributes depending on context. Remove toggles for attributes. With the ALLOWED_ATTRIBUTES filter, it's rare for an item to have more than one attribute, so hiding attributes behind a toggle doesn't save any screen space in the common case. Fix a couple of invocations of `matches!` that didn't compile on my machine. Fix a boolean for the JS `createToggle` call that was causing "Expand description" to show up spuriously on already-expanded descriptions. Add JS for auto-hide settings and hide all / show all. Remove a z-index property and some font color tweaks made unnecessary by the <details> toggles. Add CSS for the <details> toggles.
2021-04-12rustdoc: Add setting for hiding large itemsManish Goregaokar-1/+5
2021-04-12rustdoc: smartly hide associated items of traits if there are too many of themManish Goregaokar-6/+6
2021-04-12rustdoc: hide fields of structs/unions > 5Manish Goregaokar-1/+1
2021-04-12rustdoc: hide variants of enums > 5Manish Goregaokar-7/+10
2021-04-12rustdoc: Stop hiding entire item declarationsManish Goregaokar-21/+4
2021-04-05Update Source Serif to release 4.004Trevor Spiteri-15/+15
Now the family name is Source Serif 4 (upstream issue 77) instead of Source Serif Pro.
2021-04-05Rollup merge of #83717 - notriddle:main-js-slice-loop, r=GuillaumeGomezDylan DPC-9/+12
rustdoc: Separate filter-empty-string out into its own function
2021-04-02rustdoc: Remove unused `spotlight` CSSCamelid-4/+1
I couldn't find any uses of this CSS. I think it was superseded by the `.notable-traits` CSS class and other similarly-named CSS classes.
2021-04-02Rollup merge of #83721 - GuillaumeGomez:copy-use, r=Nemo157Yuki Okushi-13/+55
Add a button to copy the "use statement" Fixes https://github.com/rust-lang/rust/issues/50239 When clicking on the button, it'll add the elements prepended by "use " and will end with a ";". So in the images below, I now have in my clipboard `use std::fs::OpenOptions;`. A screenshot of the newly added button: ![Screenshot from 2021-03-31 22-12-12](https://user-images.githubusercontent.com/3050060/113205430-90e64500-926e-11eb-8538-529829f611ec.png) A screenshot after it was clicked: ![Screenshot from 2021-03-31 22-15-31](https://user-images.githubusercontent.com/3050060/113205532-ad827d00-926e-11eb-893d-35f2f8f92696.png) r? `@Nemo157`
2021-04-01rustdoc: Separate filter-empty-string out into its own functionMichael Howell-2/+11
2021-03-31Add a button to copy the "use statement"Guillaume Gomez-13/+55
2021-03-31rustdoc: use Array.prototype.filter instead of open-coding itMichael Howell-8/+2
2021-03-29Wrap non-pre code blocksIvan Tham-1/+3
Fix #83550 regression
2021-03-24Rollup merge of #83405 - r00ster91:deprecated_emoji, r=GuillaumeGomezDylan DPC-4/+13
Slight visual improvements to warning boxes in the docs First I noticed that sometimes the thumbs-down emoji in the docs is hard to see and hard to look at because the yellow emoji color and the color of the box below are so bright. Especially if you look at the screen late at night you can notice it. I thought I should change that so I added a black outline around the emoji. It works using the [`text-shadow`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow) property. It may be a bit hacky but it seems to work well and browser compatibility looks pretty good too: [browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow#browser_compatibility). For consistency the microscope has the black border too. Alternatively I had `drop-shadow(0px 0px 1px black);` in mind but its [browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/drop-shadow()#browser_compatibility) doesn't look as good and the blurry shadow probably doesn't look as good either. Then, I thought that now that I'm at it I could also try changing the purple color to a color you would rather expect to see for deprecation: red. For the red I've taken the blue and reused it as a foundation and moved it to the red color spectrum. But then I thought that the purple color could still be reused for something else: for the boxes that tell you about portability (e.g. _only supported on Unix_). These are currently blue. I think blue doesn't really represent danger like it should. Not being cross-platform represents a danger because if you want to compile for a different platform, your code may not compile anymore. Blue looks too friendly and is in my opinion more suitable for a box containing general information like for instance "This is available since 1.0.0". None of the current three box types (unstable, deprecated and portability) are that. I think purple is a better fit for it because it's kind of in the middle between "use it" and "don't use it". Deprecated is definitely "don't use it". To illustrate this better, here's a color spectrum: Blue = friendly, "use it". ![image](https://user-images.githubusercontent.com/35064754/112139891-9a6b0f80-8bd3-11eb-94e1-dc747a3d4cf9.png) Red = danger, "don't use it". And the purple in the middle (the color that the portability box now has) probably represents "use it if you have to", so it's not entirely friendly and not entirely a danger. That is why I think it fits. However I made one change to that existing purple: I made the outer color a bit brighter because it's outstandingly dark compared to the other outer colors of the other boxes. This is all subjective but in my opinion it looks nicer. At first you might need to get used to it though. Notice the box colors and the black outlines around the emoji shapes: ![image](https://user-images.githubusercontent.com/35064754/112139327-ebc6cf00-8bd2-11eb-88ac-25219b43a1a0.png) ![image](https://user-images.githubusercontent.com/35064754/112139392-000acc00-8bd3-11eb-90c2-81feec93c521.png)
2021-03-24Rollup merge of #83393 - GuillaumeGomez:codeblock-tooltip-position, r=Nemo157Dylan DPC-1/+1
Codeblock tooltip position The codeblocks tooltips were misplaced. Normally, there is no top margin applied to a tooltip unless the codeblock is the first element of the doc block. The CSS rule was too vague though, applying it to all tooltips where the codeblock was the first child of its parent. Which can be easily seen with lists: Before: ![Screenshot from 2021-03-22 22-05-16](https://user-images.githubusercontent.com/3050060/112059812-a667ba80-8b5c-11eb-88dd-1c598ceb3766.png) After: ![Screenshot from 2021-03-22 22-06-31](https://user-images.githubusercontent.com/3050060/112059815-a7005100-8b5c-11eb-9e40-8fc57513e498.png) r? ``@Nemo157``
2021-03-23Slight visual improvements to warning boxes in the docsr00ster91-4/+13
2021-03-23Rollup merge of #82732 - GuillaumeGomez:remove-theme-file, r=Nemo157Yuki Okushi-17/+78
Remove theme.js file Fixes #82616. The first commit moves the `theme.js` file into `main.js`, which requires to also run a small `.replace` on the `main.js` content. The second commit is just a small cleanup to centralize DOM ids. Since it removes a file from rustdoc output: cc `@rust-lang/docs-rs` cc `@jsha` r? `@jyn514`
2021-03-23Rollup merge of #80705 - tspiteri:italic-and-update-SourceCodePro, ↵Yuki Okushi-3/+11
r=GuillaumeGomez Update Source Code Pro and include italics Fixes #65502. #65665, a similar PR to this was merged but reverted because of https://github.com/rust-lang/rust/pull/65665#issuecomment-556860510. The issue in that comment is the upstream issue https://github.com/adobe-fonts/source-code-pro/issues/217 which should now be fixed in the upstream since [2.032R-ro/1.052R-it/1.012R-VAR release](https://github.com/adobe-fonts/source-code-pro/releases/tag/2.032R-ro/1.052R-it/1.012R-VAR), so I think this can now be merged. A couple of notes from the original PR: * Since this PR changes the font set, I think docs.rs would have to be updated if this PR is merged. * The fonts have a double extension (.ttf.woff); this is to keep the names consistent with the upstream font release which does that to distinguish these from the .otf.woff files (Source Code Pro otf renders poorly on older Windows system apps).
2021-03-22Fix codeblock tooltip positionGuillaume Gomez-1/+1
2021-03-19Ignore main.js file lengthGuillaume Gomez-0/+1
2021-03-19Only build help popup when it's really neededGuillaume Gomez-12/+19
2021-03-16Rollup merge of #83157 - nagisa:nagisa/portability-background, r=GuillaumeGomezYuki Okushi-9/+3
No background for code in portability snippets This better matches the appearance of this kind of snippet in the full item view and is less jarring to read due to repeated foreground-background changes. ![Listing of items in a module with some portability snippets attached to some of the items (light theme). The portability snippet has a light blue background and all of the text in it, monospace or not, is the same colour – black](https://user-images.githubusercontent.com/679122/111196363-1900f500-85b5-11eb-8f97-e283c59002a4.png) ![Listing of items in a module with some portability snippets attached to some of the items (dark theme). The portability snippet has a light blue background and all of the text in it, monospace or not, is the same colour – black](https://user-images.githubusercontent.com/679122/111196366-19998b80-85b5-11eb-9914-4d14d9d13ed3.png) There should be no observable changes to the ayu theme.
2021-03-16Rollup merge of #83156 - nagisa:nagisa/sans-serif-please, r=GuillaumeGomezYuki Okushi-4/+5
Fall-back to sans-serif if Arial is not available Otherwise on systems where Arial is not available the UA will fallback to a serif font, rather than a sans-serif one. This is especially relevant on acessibility-conscious setups (such as is mine) that have web-fonts disabled and a limited set of fonts available on the system. r? ```@GuillaumeGomez``` cc ```@jsha```
2021-03-16Rollup merge of #83077 - notriddle:gc-cleanup-rustdoc-search, r=GuillaumeGomezYuki Okushi-49/+78
rustdoc: reduce GC work during search
2021-03-15Declare `word` outside the loop, as recommended by eslintMichael Howell-3/+3
2021-03-15No background for code in portability snippetsSimonas Kazlauskas-9/+3
This better matches the appearance of this kind of snippet in the full item view and is less jarring to read due to repeated foreground-background changes.
2021-03-15Fall-back to sans-serif if Arial is not availableSimonas Kazlauskas-4/+5
Otherwise on systems where Arial is not available the system will fallback to a serif font, rather than a sans-serif one. This is especially relevant on acessibility-conscious setups (such as is mine) that have web-fonts disabled and a limited set of fonts available on the system.
2021-03-14Make nameWithoutUndescores lowercasedMichael Howell-14/+15
This basically fixes a search bug introduced by earlier changes.
2021-03-14Use a number for row.id, instead of a stringMichael Howell-11/+5
There's no reason for it to be a string, since it's only used for de-duplicating the results arrays anyhow.
2021-03-14Avoid generating new strings for names that have no undescoresMichael Howell-2/+8
This should have negligible effect on time, but it cuts about 1MiB off of resident memory usage.
2021-03-14Auto merge of #83028 - GuillaumeGomez:prevent-js-error-if-no-filter, r=Nemo157bors-1/+5
Prevent JS error when there is no dependency or other crate documented (or --disable-per-crate-search has been used) When there is only one crate, the dropdown is removed, creating an error (that you can see pretty easily on docs.rs for example). r? `@jyn514`
2021-03-13Remove tab characterMichael Howell-2/+2
2021-03-13Avoid potential collisions with `constructor` and the search queryMichael Howell-2/+2
2021-03-13Add comments regarding object shapes in buildIndexMichael Howell-0/+5
2021-03-13Fix jslint warningsMichael Howell-2/+3
2021-03-13Use null instead of undefined hereMichael Howell-2/+2
2021-03-13Update src/librustdoc/html/static/main.jsMichael Howell-1/+1
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2021-03-13Eagerly generate the underscore-less name to search onMichael Howell-2/+4
Basically, it doesn't make sense to generate those things every time you search. That generates a bunch of stuff for the GC to clean up, when, if the user wanted to do another search, it would just need to re-do it again.
2021-03-13In checkGenerics and checkType, don't use Array.prototype.splice so muchMichael Howell-37/+57
Every time splice() is called, another temporary object is created. This version, which uses plain objects as a sort of Hash Bag, should only produce one temporary object each time it's called.
2021-03-12Get rid of the garbage produced by getObjectFromIdMichael Howell-7/+7
There is no reason for this function to return an object, since it is always used for getting at the name anyhow. It's used in the inner loop for some popular functions, so we want to avoid allocating in it.
2021-03-12Rollup merge of #83003 - notriddle:rustdoc-index-v3, r=GuillaumeGomezYuki Okushi-19/+20
rustdoc: tweak the search index format This essentially switches search-index.js from a "array of struct" to a "struct of array" format, like this: { "doc": "Crate documentation", "t": [ 1, 1, 2, 3, ... ], "n": [ "Something", "SomethingElse", "whatever", "do_stuff", ... ], "q": [ "a::b", "", "", "", ... ], "d": [ "A Struct That Does Something", "Another Struct", "a function", "another function", ... ], "i": [ 0, 0, 1, 1, ... ], "f": [ null, null, [], [], ... ], "p": ..., "a": ... } So `{ty: 1, name: "Something", path: "a::b", desc: "A Struct That Does Something", parent_idx: 0, search_type: null}` is the first item. This makes the uncompressed version smaller, but it really shows on the compressed version: notriddle:rust$ wc -c new-search-index1.52.0.js 2622427 new-search-index1.52.0.js notriddle:rust$ wc -c old-search-index1.52.0.js 2725046 old-search-index1.52.0.js notriddle:rust$ gzip new-search-index1.52.0.js notriddle:rust$ gzip old-search-index1.52.0.js notriddle:rust$ wc -c new-search-index1.52.0.js.gz 239385 new-search-index1.52.0.js.gz notriddle:rust$ wc -c old-search-index1.52.0.js.gz 296328 old-search-index1.52.0.js.gz That's a 4% improvement on the uncompressed version (fewer `[]`, and also changing `null` to `0` in the parent_idx list), and 20% improvement after gzipping it, thanks to putting like-typed data next to each other. Any compression algorithm based on a sliding window will probably show this kind of improvement.
2021-03-12Rollup merge of #82979 - GuillaumeGomez:run-button-pos, r=Nemo157Yuki Okushi-1/+1
Fix "run" button position in error index This isn't really a rustdoc issue but I still made the same fix in the `rustdoc.css` file (doesn't hurt). Before: ![Screenshot from 2021-03-10 16-35-49](https://user-images.githubusercontent.com/3050060/110655807-aa402800-81bf-11eb-8a88-bc979efd1697.png) After: ![Screenshot from 2021-03-10 16-40-08](https://user-images.githubusercontent.com/3050060/110655843-b4622680-81bf-11eb-8670-42975d92b4eb.png) cc ````@jyn514```` (considering this is quite a big bug and an easy fix) r? ````@Nemo157````
2021-03-11Prevent JS error when there is no dependency or other crate documentedGuillaume Gomez-1/+5