about summary refs log tree commit diff
path: root/src/librustdoc/html/render/write_shared.rs
AgeCommit message (Collapse)AuthorLines
2022-01-14Auto merge of #91948 - nnethercote:rustdoc-more-Symbols, r=GuillaumeGomezbors-1/+1
rustdoc: avoid many `Symbol` to `String` conversions. Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples. r? `@GuillaumeGomez`
2022-01-14rustdoc: avoid many `Symbol` to `String` conversions.Nicholas Nethercote-1/+1
Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples.
2022-01-13Use the updated Rust logo and change it's format to SVGLoïc BRANSTETT-1/+1
2022-01-10Migrate rustdoc from Tera to AskamaDirkjan Ochtman-8/+1
See #84419.
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-3/+3
2021-11-24Consistentize the system for image URLs in CSS.Jacob Hoffman-Andrews-28/+20
2021-11-24Move themes and version into rustdoc-varsJacob Hoffman-Andrews-32/+2
We had been injecting the list of themes and the rustdoc version into main.js by rewriting it at doc generation time. By avoiding this rewrite, we can make it easier to edit main.js without regenerating all the docs. Added a more convenient accessor for rustdoc-vars. Changed storage.js to not rely on resourcesSuffix. It could in theory use rustdoc-vars, but because rustdoc-vars is at the end of the HTML, it's not available when storage.js runs (very early in page load).
2021-11-24Simplify rendering of stylesheet links into HTMLJacob Hoffman-Andrews-2/+2
We carry around a list of stylesheets that can carry two different types of thing: 1. Internal stylesheets specific to a page type (only for settings) 2. Themes In this change I move the link generation for settings.css into settings(), so Context.style_files is reserved just for themes. We had two places where we extracted a base theme name from a list of StylePaths. I consolidated that code to be a method on StylePath. I moved generation of link tags for stylesheets into the page.html template. With that change, I made the template responsible for special handling of light.css (making it the default theme) and of the other themes (marking them disabled). That allowed getting rid of the `disabled` field on StylePath.
2021-11-07rustdoc: Remove top-level wrappers for `ImplKind` methodsNoah Lev-1/+1
The `ImplKind` methods can just be used directly instead.
2021-11-07rustdoc: Refactor `Impl.{synthetic,blanket_impl}` into enumNoah Lev-1/+1
This change has two advantages: 1. It makes the possible states clearer, and it makes it impossible to construct invalid states, such as a blanket impl that is also an auto trait impl. 2. It shrinks the size of `Impl` a bit, since now there is only one field, rather than two.
2021-10-31Auto merge of #90391 - camelid:crate-size, r=jyn514bors-6/+7
rustdoc: Compute some fields of `clean::Crate` on-demand to reduce size `clean::Crate` is frequently moved by-value -- for example, in `DocFolder` implementations -- so reducing its size should improve performance. This PR reduces the size of `clean::Crate` from 168 bytes to 104 bytes. r? `@jyn514`
2021-10-30rustdoc: Remove `Crate.name` and instead compute it on-demandNoah Lev-6/+7
It is not as large as `Crate.src` was, but it's still 8 bytes, and `clean::Crate` is moved by-value a lot.
2021-10-30Remove unnecessary `macro_use`s in rustdocJoshua Nelson-0/+1
2021-10-27Rollup merge of #90232 - konan8205:master, r=GuillaumeGomezMatthias Krüger-3/+3
rustdoc: Use TTF based font instead of OTF for CJK glyphs to improve readability Due to Windows' implementation of font rendering, OpenType fonts can be distorted. So the existing font, Noto Sans KR, is not very readable on Windows. This PR improves readability of Korean glyphs on Windows. ## Before ![원1](https://user-images.githubusercontent.com/11029378/138592394-16b15787-532d-4421-a5eb-ed85675290fa.png) ## After ![원2](https://user-images.githubusercontent.com/11029378/138592409-f3a440ee-f0fc-40e4-9561-42c479439c9f.png) The fonts included in this PR are licensed under the SIL Open Font License and generated with these commands: ```sh pyftsubset NanumBarunGothic.ttf \ --unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \ --output-file=NanumBarunGothic.ttf.woff --flavor=woff ``` ```sh pyftsubset NanumBarunGothic.ttf \ --unicodes=U+AC00-D7AF,U+1100-11FF,U+3130-318F,U+A960-A97F,U+D7B0-D7FF \ --output-file=NanumBarunGothic.ttf.woff2 --flavor=woff2 ``` r? ``@GuillaumeGomez``
2021-10-26rustdoc: use ttf based font for cjk glyphsShinwoo Park-3/+3
2021-10-25Fix clippy lints in librustdocGuillaume Gomez-1/+1
2021-10-23Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514Matthias Krüger-0/+9
Scrape code examples from examples/ directory for Rustdoc Adds support for the functionality described in https://github.com/rust-lang/rfcs/pull/3123 Matching changes to Cargo are here: https://github.com/rust-lang/cargo/pull/9525 Live demo here: https://willcrichton.net/example-analyzer/warp/trait.Filter.html#method.and
2021-10-12rustdoc: update noto sans krShinwoo Park-2/+3
2021-10-06Unversioned -> InvocationSpecificWill Crichton-1/+1
2021-10-06Fix lint error, change scrape-examples.js minify callWill Crichton-1/+6
2021-10-06Move JS into a standalone fileWill Crichton-0/+4
2021-09-17Add rustdoc version into the help popupGuillaume Gomez-4/+12
2021-09-16Auto merge of #88219 - jyn514:parallel-io, r=GuillaumeGomezbors-31/+39
rustdoc: reduce number of copies when using parallel IO This is Windows-only for now; I was getting really bad slowdowns from this on linux for some reason. Helps with https://github.com/rust-lang/rust/issues/82741. Follow-up to https://github.com/rust-lang/rust/pull/60971.
2021-08-26Remove unnecessary copies when using parallel IOJoshua Nelson-31/+39
Previously, rustdoc was making lots of copies of temporary owned values. Now, it uses the owned value wherever possible.
2021-08-22Move Cache from Context to SharedContextJoshua Nelson-5/+6
2021-08-05Add links on source types to go to definitionGuillaume Gomez-2/+2
2021-08-03Simplify usage of CSS background-imageGuillaume Gomez-6/+41
2021-08-03Rustdoc accessibility: use an icon for the [-]/[+] controlsMichael Howell-2/+5
This way, we can show the plus and minus buttons on screens, while voice control will read off actual words "Collapse" and "Expand" instead of reading "open brace minus close brace" and "open brace plus close brace". Part of #87059
2021-06-22Rollup merge of #86402 - tspiteri:source-woff2, r=jshaYuki Okushi-0/+6
rustdoc: add optional woff2 versions of Source Serif and Source Code This provides woff2 versions of Source Serif and Source Code similar to how #82545 provides woff2 versions of Fira Sans. The total byte count for the six files (three for each font family) is reduced by 25% from 476 KiB to 358 KiB.
2021-06-20Use Tera templates for rustdoc.Jacob Hoffman-Andrews-1/+8
Replaces a format!() call in layout::render with a template expansion. Introduces a `templates` field in SharedContext so parts of rustdoc can share pre-rendered templates. This currently builds in a copy of the single template available, like with static files. However, future work can make this live-loadable with a perma-unstable flag, to make rustdoc developers' work easier.
2021-06-17rustdoc: add optional woff2 versions of Source Serif and Source CodeTrevor Spiteri-0/+6
2021-05-31Remove unneeded file to load sidebar items at crate levelGuillaume Gomez-1/+0
2021-05-28Remove `--print unversioned-files` from rustdocBoris-Chengbiao Zhou-1/+1
This flag isn't needed anymore. See #83784.
2021-05-26Rollup merge of #84048 - konan8205:master, r=jshaYuki Okushi-0/+2
Avoid CJK legacy fonts in Windows As metioned in #84035, the default serif CJK font in Windows is meh-looking. To avoid this, we should use sans-serif font or provide CJK glyph supported font in `rustdoc.css`.
2021-05-16Auto merge of #85304 - Stupremee:crates-in-sidebar-in-root, r=Nemo157bors-0/+2
rustdoc: Call `initSidebarItems` in root module of crate r? `@jsha` Resolves #85301
2021-05-15Call `initSidebarItems` in root module of crateJustus K-0/+2
2021-05-15Minimize amount of fake `DefId`s used in rustdocJustus K-2/+0
2021-05-15rustdoc: update static filesShinwoo Park-0/+2
2021-05-10Use an SVG image for clipboard instead of unicode characterGuillaume Gomez-0/+1
2021-05-04Add type to differentiate between fake and real DefId'sJustus K-1/+3
2021-04-22Remove unnecessary `edition` field on SharedContextJoshua Nelson-1/+1
2021-04-17Rollup merge of #84150 - jsha:defer-search-js, r=GuillaumeGomezDylan DPC-1/+2
rustdoc: move some search code into search.js This reduces main.s from 3094 lines to 1587. Also it saves some bytes of download in the case where search isn't used. There were a fair number of variables that needed to be accessible in both main.js and search.js, but I didn't want to put too many symbols in the global namespace, so I consolidated much of the search-related state and functions into a new object `window.searchState`. Demo at https://hoffman-andrews.com/rust/move-search/std/?search=foo
2021-04-17rustdoc: use more precise relative URLSMichael Howell-2/+1
Instead of using a depth counter and adding "../" to get to the top, this commit makes rustdoc actually compare the path of what it's linking from to the path that it's linking to. This makes the resulting HTML shorter. Here's a comparison of one of the largest (non-source) files in the Rust standard library docs (about 4% improvement before gzipping). $ wc -c struct.Wrapping.old.html struct.Wrapping.new.html 2387389 struct.Wrapping.old.html 2298538 struct.Wrapping.new.html Most if it can be efficiently gzipped away. $ wc -c struct.Wrapping.old.html.gz struct.Wrapping.new.html.gz 70679 struct.Wrapping.old.html.gz 70050 struct.Wrapping.new.html.gz But it also makes a difference in the final DOM size, reducing it from 91MiB to 82MiB.
2021-04-13Split search.js from search-index.js.Jacob Hoffman-Andrews-2/+4
2021-04-12Move search JS into search-index.jsJacob Hoffman-Andrews-3/+2
Export a few variables and functions into the global scope because they are needed both by main.js and search-index.js.
2021-04-05Update Source Serif to release 4.004Trevor Spiteri-4/+4
Now the family name is Source Serif 4 (upstream issue 77) instead of Source Serif Pro.
2021-04-02Rollup merge of #83478 - jyn514:fine-grained-files, r=Mark-SimulacrumDylan DPC-121/+173
rustdoc: Add unstable option to only emit shared/crate-specific files The intended use case is for docs.rs, which can now copy exactly the files it cares about, rather than having to guess based on whether they have a resource suffix or not. In particular, some files have a resource suffix but cannot be shared between crates: https://github.com/rust-lang/docs.rs/pull/1312#issuecomment-798783688 The end goal is to fix rust-lang/docs.rs#1327 by reverting rust-lang/docs.rs#1324. This obsoletes `--print=unversioned-files`, which I plan to remove as soon as docs.rs stops using it. I recommend reviewing this one commit at a time. r? ``@GuillaumeGomez`` cc ``@Nemo157`` ``@pietroalbini``
2021-03-31Fix `--external-css` to be invocation-specific and note main.js should be ↵Joshua Nelson-1/+10
invocation specific
2021-03-31Rename CrateSpecific -> InvocationSpecificJoshua Nelson-7/+7
2021-03-31Enforce that Toolchain files are static and Crate files are dynamicJoshua Nelson-28/+35
This also changes custom themes from Toolchain to Crate files.