about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2021-11-18rustdoc: Avoid using `Iterator::count()` where possibleNoah Lev-1/+1
`count()` iterates over the whole collection. Using `len()` instead, or `.next().is_none()` when comparing to zero, should be faster.
2021-11-17Make scrollbar in the sidebar always visible for visual consistencyGuillaume Gomez-4/+4
2021-11-14Auto merge of #90757 - GuillaumeGomez:search-index-performance, r=camelidbors-4/+0
Remove unneeded FIXMEs comments in search index generation Original comment: > Instead of recreating a new `vec` for each arguments, we re-use the same. The impact on performance should be minor but worth a try. After testing it, we reached the conclusion that the code readability drop wasn't worth the almost unnoticeable performance improvement. r? `@camelid`
2021-11-14Auto merge of #90883 - matthiaskrgr:rollup-iu9k5pe, r=matthiaskrgrbors-13/+7
Rollup of 3 pull requests Successful merges: - #90771 (Fix trait object error code) - #90840 (relate lifetime in `TypeOutlives` bounds on drop impls) - #90853 (rustdoc: Use an empty Vec instead of Option<Vec>) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-13Auto merge of #90385 - mfrw:mfrw/librustdoc, r=GuillaumeGomezbors-13/+24
rustdoc: use Type::def_id() instead of Type::def_id_no_primitives() For: #90187 r? `@jyn514`
2021-11-12Use an empty Vec instead of Option<Vec>Michael Howell-13/+7
2021-11-12Rollup merge of #90795 - GuillaumeGomez:more-search-index-comments, r=notriddleMatthias Krüger-2/+13
Add more comments to explain the code to generate the search index Fixes #90766. I tried to put comments when the code wasn't easy to understand at first sight and added more documentation on the recursive function. Please tell me if I misused the terminology or if comments can be improved or added into other places. r? `@notriddle`
2021-11-12Add more comments to explain the code to generate the search indexGuillaume Gomez-2/+13
2021-11-12Remove unneeded FIXME: after testing the suggested changes, we reached the ↵Guillaume Gomez-4/+0
conclusion that the code readibility wasn't worth the almost unnoticeable perf improvement
2021-11-11Use `Iterator::collect` instead of calling `Vec::push` in a loopMichael Howell-23/+26
2021-11-11librustdoc: revert use of def_id for one of the edge caseMuhammad Falak R Wani-5/+10
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2021-11-10Remove potential useless data for search indexGuillaume Gomez-39/+46
2021-11-07rustdoc: Remove top-level wrappers for `ImplKind` methodsNoah Lev-7/+7
The `ImplKind` methods can just be used directly instead.
2021-11-07rustdoc: Use `ty::ImplPolarity` instead of custom enumNoah Lev-6/+8
2021-11-07Use an enum to record polarity in `clean::Impl`Noah Lev-8/+9
2021-11-07rustdoc: Refactor `Impl.{synthetic,blanket_impl}` into enumNoah Lev-9/+8
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-11-05Auto merge of #90583 - willcrichton:example-analyzer, r=jyn514bors-1/+7
Fix ICE when rustdoc is scraping examples inside of a proc macro This PR provides a clearer semantics for how --scrape-examples interacts with macros. If an expression's span AND it's enclosing item's span both are not `from_expansion`, then the example will be scraped. The added test case `rustdoc-scrape-examples-macros` shows a variety of situations. * A macro-rules macro that takes a function call as input: good * A macro-rules macro that generates a function call as output: bad * A proc-macro that generates a function call as output: bad * An attribute macro that generates a function call as output: bad * An attribute macro that takes a function call as input: good, if the proc macro is designed to propagate the input spans I ran this updated rustdoc on pyo3 and confirmed that it successfully scrapes examples from inside a proc macro, eg <img width="1013" alt="Screen Shot 2021-11-04 at 1 11 28 PM" src="https://user-images.githubusercontent.com/663326/140412691-81a3bb6b-a448-4a1b-a293-f7a795553634.png"> (cc `@mejrs)` Additionally, this PR fixes an ordering bug in the highlighting logic. Fixes https://github.com/rust-lang/rust/issues/90567. r? `@jyn514`
2021-11-05rustdoc: use Type::def_id() instead of Type::def_id_no_primitives()Muhammad Falak R Wani-22/+28
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2021-11-05Rollup merge of #90571 - GuillaumeGomez:missing-bottom-border-sidebar, r=jshaYuki Okushi-3/+9
Fix missing bottom border for headings in sidebar Fixes #90568. r? ```@jsha```
2021-11-04Sort scraped call locations before serializingWill Crichton-1/+7
2021-11-04Fix missing bottom border for headings in sidebarGuillaume Gomez-3/+9
2021-11-03Auto merge of #90475 - camelid:docvisitor, r=notriddlebors-36/+40
rustdoc: Add `DocVisitor` and use it where possible `DocFolder` allows transforming the docs, accomplished by making its methods take and return types by-value. However, several of the rustdoc `DocFolder` impls only *visit* the docs; they don't change anything. Passing around types by-value is thus unnecessary, confusing, and potentially inefficient for those impls. `DocVisitor` is very similar to `DocFolder`, except that its methods take shared references and return nothing (i.e., the unit type). This should both be more efficient and make the code clearer. There is an additional reason to add `DocVisitor`, too. As part of my cleanup of `external_traits`, I'm planning to add a `fn cache(&mut self) -> &mut Cache` method to `DocFolder` so that `external_traits` can be retrieved explicitly from the `Cache`, rather than implicitly via `Crate.external_traits` (which is an `Rc<RefCell<...>>`). However, some of the `DocFolder` impls that could be turned into `DocVisitor` impls only have a shared reference to the `Cache`, because they are used during rendering. (They have to access the `Cache` via `html::render::Context.shared.cache`, which involves an `Rc`.) Since `DocVisitor` does not mutate any of the types it's visiting, its equivalent `cache()` method will only need a shared reference to the `Cache`, avoiding the problem described above. r? `@GuillaumeGomez` cc `@jyn514`
2021-11-02Add line number to URLs in "additional examples" section of rustdocWill Crichton-13/+20
2021-11-02Fix URL for scrape-examples.js in rustdoc page templateWill Crichton-3/+3
2021-10-31rustdoc: Small micro-optimizations and cleanupsNoah Lev-7/+8
* Flip conjuncts of `&&` in rustdoc The `CrateNum` comparison should be very cheap, while `span.filename()` fetches and clones a `FileName`. * Use `into_local_path()` instead of `local_path().clone()`
2021-10-31Fix FIXMEs in `rustdoc::html::sources`Noah Lev-5/+6
One of the FIXMEs is irrelevant since that code is only run if `include_sources` is set. I fixed the other FIXME.
2021-10-31Clean up now that visitors only need `&clean::Crate`Noah Lev-15/+15
2021-10-31rustdoc: Use `DocVisitor` for sources collectionNoah Lev-12/+14
2021-10-31Hide search bar in noscript.cssJacob Hoffman-Andrews-14/+12
Also, remove the highlighting of the search bar in disabled state. This reduces flicker when loading a page.
2021-10-31Auto merge of #90391 - camelid:crate-size, r=jyn514bors-12/+13
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-30Improve display of enum variantsJacob Hoffman-Andrews-26/+27
Use h3 and h4 for the variant name and the "Fields" subheading. Remove the "of T" part of the "Fields" subheading. Remove border-bottom from "Fields" subheading. Move docblock below "Fields" listing.
2021-10-30Rollup merge of #90183 - GuillaumeGomez:recurse-deref, r=jyn514Guillaume Gomez-18/+85
Show all Deref implementations recursively Fixes #87783. This is a re-implementation of #80653, so taking the original PR comment: This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level. ![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png) cc `@camelid` r? `@jyn514`
2021-10-30Rollup merge of #90156 - jsha:less-border-bottom-2, r=GuillaumeGomezGuillaume Gomez-2/+9
Remove underlines from non-top docblocks. We still had a number of places where underlined section headings would show up, like under Implementations. Follow-up to #89506 (thanks `@yaymukund!)` and #90036. Related to #59829. r? `@camelid` Demo: [Before](https://doc.rust-lang.org/nightly/std/string/struct.String.html#trait-implementations): [![image](https://user-images.githubusercontent.com/220205/138402555-b0c0a3ea-ff50-4aad-bb74-6f9e57323807.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations) [After](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations): [![image](https://user-images.githubusercontent.com/220205/138402669-d0835bd9-8813-4f0c-8697-f86e9759acec.png)](https://jacob.hoffman-andrews.com/rust/less-border-bottom-2/std/string/struct.String.html#trait-implementations)
2021-10-30rustdoc: Remove `Crate.name` and instead compute it on-demandNoah Lev-11/+12
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-30rustdoc: Remove `Crate.src` and instead compute it on-demandNoah Lev-1/+1
It is only used in one place; `src` was about a third of `Crate`'s total size; `Crate` is frequently moved by-value; and `src` can be easily computed on-demand.
2021-10-30Remove underlines from non-top docblocks.Jacob Hoffman-Andrews-2/+9
We still had a number of places where underlined section headings would show up, like under Implementations.
2021-10-30Rollup merge of #90412 - jyn514:macro-use, r=camelidMatthias Krüger-2/+4
Remove unnecessary `macro_use`s in rustdoc
2021-10-30Remove unnecessary `macro_use`s in rustdocJoshua Nelson-2/+4
2021-10-29Fix invalid handling of genericsGuillaume Gomez-89/+121
2021-10-29Don't display "Methods from Deref<...>" if no method is display (the ones ↵Guillaume Gomez-3/+9
which don't have `self` argument)
2021-10-29Remove the Rc wrapping of deref_id_mapGuillaume Gomez-4/+4
2021-10-29Recursively document DerefGuillaume Gomez-15/+76
2021-10-27Auto merge of #90186 - jsha:fix-header-sizes, r=GuillaumeGomezbors-5/+5
Fix documentation header sizes And add a rustdoc-gui test confirming various header sizes. Split off from #90156. This fixes a regression in #89506 where the heading level of titles within Markdown was too high (h2) for docblocks under structs, unions, and enum impls. r? `@camelid` Demo: https://jacob.hoffman-andrews.com/rust/fix-header-sizes/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E Stable: https://doc.rust-lang.org/stable/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E Beta: https://doc.rust-lang.org/beta/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
2021-10-27Rollup merge of #90278 - notriddle:notriddle/highlight-ptr, ↵Matthias Krüger-8/+23
r=jyn541,GuillaumeGomez rustdoc: use better highlighting for *const, *mut, and &mut This generates more consistent HTML for these RefKeyWord combinations. Before: ![image](https://user-images.githubusercontent.com/1593513/138742752-7e00a3f7-4621-4c62-82d1-3e4c2ef503d1.png) After: ![image](https://user-images.githubusercontent.com/1593513/138743955-90abcdcd-fc88-4e2f-95bb-c1b1635c0001.png)
2021-10-27Rollup merge of #90232 - konan8205:master, r=GuillaumeGomezMatthias Krüger-21/+47
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-27Rollup merge of #90154 - camelid:remove-getdefid, r=jyn514Matthias Krüger-20/+20
rustdoc: Remove `GetDefId` See the individual commit messages for details. r? `@jyn514`
2021-10-26rustdoc: use ttf based font for cjk glyphsShinwoo Park-21/+47
2021-10-25Fix documentation header sizesJacob Hoffman-Andrews-5/+5
And add a rustdoc-gui test confirming various header sizes.
2021-10-25Auto merge of #89430 - GuillaumeGomez:rustdoc-clippy-lints, ↵bors-119/+98
r=jyn514,camelid,notriddle Fix clippy lints in librustdoc I ran clippy on librustdoc and simply fixed the lints. :) r? `@notriddle`
2021-10-25rustdoc: use better highlighting for *const, *mut, and &mutMichael Howell-8/+23
This generates more consistent HTML for these RefKeyWord combinations. Before: ![image](https://user-images.githubusercontent.com/1593513/138742752-7e00a3f7-4621-4c62-82d1-3e4c2ef503d1.png) After: ![image](https://user-images.githubusercontent.com/1593513/138743955-90abcdcd-fc88-4e2f-95bb-c1b1635c0001.png)