about summary refs log tree commit diff
path: root/src/librustdoc/html
AgeCommit message (Collapse)AuthorLines
2021-09-08Auto merge of #87489 - bdalrhm:rustdoc-line-num, r=CraftSpiderbors-1/+29
`rustdoc`: compute correct line number for indented rust code blocks. This PR fixes a bug in `rustdoc` where it computes the wrong line number for indented rust code blocks (and subsequent blocks) it finds in markdown strings. To fix this issue, we decrement the line number if we find characters between the code block and the preceding line ending. I noticed this issue as I was trying to use `rustdoc` to extract examples from The Rust Reference and run them through the [Rust Model Checker](https://github.com/model-checking/rmc).
2021-09-06fix ICE on hidden tuple variant fieldsEmil Gardström-24/+27
this also renders them as `_`, which rustdoc previously did not.
2021-09-06Correctly handle niche of enumDeadbeef-4/+8
2021-09-05Auto merge of #88435 - cjgillot:no-walk-crate, r=Aaron1011bors-1/+1
Avoid invoking the hir_crate query to traverse the HIR Walking the HIR tree is done using the `hir_crate` query. However, this is unnecessary, since `hir_owner(CRATE_DEF_ID)` provides the same information. Since depending on `hir_crate` forces dependents to always be executed, this leads to unnecessary work. By splitting HIR and attributes visits, we can avoid an edge to `hir_crate` when trying to visit the HIR tree.
2021-09-05Change more x64 size checks to not apply to x32.Harald van Dijk-1/+1
Commit 95e096d6 changed a bunch of size checks already, but more have been added, so this fixes the new ones the same way: the various size checks that are conditional on target_arch = "x86_64" were not intended to apply to x86_64-unknown-linux-gnux32, so add target_pointer_width = "64" to the conditions.
2021-09-05Auto merge of #88604 - camelid:rustdoc-lifetime-bounds, r=GuillaumeGomezbors-4/+18
rustdoc: Clean up handling of lifetime bounds Previously, rustdoc recorded lifetime bounds by rendering them into the name of the lifetime parameter. Now, it leaves the name as the actual name and instead records lifetime bounds in an `outlives` list, similar to how type parameter bounds are recorded. Also, higher-ranked lifetimes cannot currently have bounds, so I simplified the code to reflect that. r? `@GuillaumeGomez`
2021-09-03Enable all main body Markdown options for summariesNoah Lev-2/+6
This fixes odd renderings when these features are used in the first paragraph of documentation for an item. This is an extension of #87270.
2021-09-03Use `summary_opts()` for Markdown summariesNoah Lev-8/+9
It was accidentally changed to use `opts()` in #86451. I also renamed `opts()` to `main_body_opts()` to make this kind of accidental change less likely.
2021-09-02rustdoc: Clean up handling of lifetime boundsNoah Lev-4/+18
Previously, rustdoc recorded lifetime bounds by rendering them into the name of the lifetime parameter. Now, it leaves the name as the actual name and instead records lifetime bounds in an `outlives` list, similar to how type parameter bounds are recorded.
2021-09-02Rename walk_crate.Camille GILLOT-1/+1
2021-09-02Stop using walk_crate.Camille GILLOT-1/+1
2021-09-02Auto merge of #88516 - matthiaskrgr:clippy_perf_end_august, ↵bors-4/+3
r=jyn514,GuillaumeGomez some low hanging clippy::perf fixes
2021-09-01Auto merge of #88490 - GuillaumeGomez:associated-types-implementors-display, ↵bors-38/+81
r=camelid,Manishearth Display associated types of implementors Fixes #86631. Contrary to before, it doesn't display methods. I also had to "resurrect" the `auto-hide-trait-implementations` setting. :3 Only question at this point: should I move the `render_impl` boolean arguments into one struct? We're starting to have quite a lot of them... cc `@cynecx` r? `@camelid`
2021-09-01Remove implementors settingGuillaume Gomez-6/+0
2021-09-01Clean render_impl argumentsGuillaume Gomez-46/+67
2021-09-01Rollup merge of #88410 - camelid:fix-assoc-bold, r=GuillaumeGomezMara Bos-1/+1
Remove bolding on associated constants Associated types don't get bolded, so it looks off to have one kind bolded and one not.
2021-08-31some low hanging clippy::perf fixesMatthias Krüger-4/+3
2021-08-31Remove bolding on associated constantsNoah Lev-1/+1
Associated types don't get bolded, so it looks off to have one kind bolded and one not.
2021-08-31Rollup merge of #88391 - GuillaumeGomez:fix-json-enum-variant, ↵Mara Bos-17/+24
r=camelid,notriddle Fix json tuple struct enum variant Fixes #87887. cc `@dsherret` `@camelid` r? `@notriddle`
2021-08-31Apply suggestionsDeadbeef-3/+2
2021-08-31Report variant size without the discriminantDeadbeef-7/+13
2021-08-31Apply suggestionsDeadbeef-26/+18
2021-08-31Report Layout of enum variantsDeadbeef-1/+35
Followup of #83501, Fixes #86253.
2021-08-30Put back "auto-collapse-implementors" settingGuillaume Gomez-0/+6
2021-08-30Put back display of associated items (types and consts)Guillaume Gomez-11/+33
2021-08-29Rollup merge of #88419 - GuillaumeGomez:code-blocks-colors, r=camelid,notriddleGuillaume Gomez-1/+1
Fix code blocks color in Ayu theme Fixes #88415. cc `@camelid` r? `@notriddle`
2021-08-29Rollup merge of #88173 - camelid:refactor-markdown-length-limit, ↵Guillaume Gomez-43/+270
r=GuillaumeGomez Refactor Markdown length-limited summary implementation This PR is a new approach to #79749. This PR refactors the implementation of `markdown_summary_with_limit()`, separating the logic of determining when the limit has been reached from the actual rendering process. The main advantage of the new approach is that it guarantees that all HTML tags are closed, whereas the previous implementation could generate tags that were never closed. It also ensures that no empty tags are generated (e.g., `<em></em>`). The new implementation consists of a general-purpose struct `HtmlWithLimit` that manages the length-limiting logic and a function `markdown_summary_with_limit()` that renders Markdown to HTML using the struct. r? `@GuillaumeGomez`
2021-08-29Use the correct type for Enum variant tuplesGuillaume Gomez-17/+24
2021-08-28Fix code blocks color in ayu themeGuillaume Gomez-1/+1
2021-08-27Introduce `~const`Deadbeef-1/+1
- [x] Removed `?const` and change uses of `?const` - [x] Added `~const` to the AST. It is gated behind const_trait_impl. - [x] Validate `~const` in ast_validation. - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and `ConstIfConst` allowing future extensions) - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`. - [ ] Optional steps (*for this PR, obviously*) - [ ] Fix #88155 - [ ] Do something with constness bounds in chalk
2021-08-26Remove unnecessary copies when using parallel IOJoshua Nelson-39/+47
Previously, rustdoc was making lots of copies of temporary owned values. Now, it uses the owned value wherever possible.
2021-08-26Auto merge of #88222 - jyn514:shared-cache, r=GuillaumeGomezbors-49/+38
rustdoc: Move Cache from Context to SharedContext r? `@camelid`
2021-08-25Don't panic if `close_tag()` is called without tags to closeNoah Lev-3/+14
This can happen when a tag is opened after the length limit is reached; the tag will not end up being added to `unclosed_tags` because the queue will never be flushed. So, now, if the `unclosed_tags` stack is empty, `close_tag()` does nothing. This change fixes a panic in the `limit_0` unit test.
2021-08-25Assert that `tag_name` is alphabeticNoah Lev-0/+8
2021-08-25Add tests for `HtmlWithLimit`Noah Lev-0/+122
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1
2021-08-22Move Cache from Context to SharedContextJoshua Nelson-49/+38
2021-08-21Use `write!`Noah Lev-6/+2
2021-08-21Use the length limit as the initial capacityNoah Lev-2/+11
The length limit turns out to be a surprisingly good heuristic for initial allocation size. See here for more details [1]. [1]: https://github.com/rust-lang/rust/pull/88173#discussion_r692531631
2021-08-21Clarify wording in docsNoah Lev-1/+1
2021-08-19Refactor Markdown length-limited summary implementationNoah Lev-43/+124
This commit refactors the implementation of `markdown_summary_with_limit()`, separating the logic of determining when the limit has been reached from the actual rendering process. The main advantage of the new approach is that it guarantees that all HTML tags are closed, whereas the previous implementation could generate tags that were never closed. It also ensures that no empty tags are generated (e.g., `<em></em>`). The new implementation consists of a general-purpose struct `HtmlWithLimit` that manages the length-limiting logic and a function `markdown_summary_with_limit()` that renders Markdown to HTML using the struct.
2021-08-19Rollup merge of #88093 - Kobzol:rustdoc-wrap-code-in-code-tag, r=GuillaumeGomezGuillaume Gomez-266/+294
[rustdoc] Wrap code blocks in <code> tag This PR modifies Rustdoc output so that fenced code snippets, items and whole file source codes are wrapped in `<pre><code>` instead of just `<pre>`. This should improve the semantic meaning of the generated content. I'm not sure what to do about `render_attributes_in_pre` and `render_attributes_in_code`. These functions were clearly expected to be used for things inside `<pre>` or `<code>`, and since I added `<code>` in this PR, some of them will be used in a different context than before. However, it seems to me that even before they were not consistent. For example, `item_constant` used `render_attributes_in_code` for its attributes, however there was no `<code>` used for constants before this PR... Should I create some `rustdoc-gui` tests? For example to check that all `<pre>` tags have a `<code>` child? Fixes: https://github.com/rust-lang/rust/issues/88020
2021-08-19[rustdoc] Wrap code blocks in <code> tagJakub Beránek-266/+294
2021-08-18Rollup merge of #88111 - GuillaumeGomez:background-color-jump-to-def, r=jhprattGuillaume Gomez-0/+9
Add background-color on clickable definitions in source code Someone suggested to add a decoration on clickable elements in the source code pages: ![Screenshot from 2021-08-17 14-49-39](https://user-images.githubusercontent.com/3050060/129728911-def74f9e-50e2-40d2-b512-e23f1b3d0409.png) ![Screenshot from 2021-08-17 14-49-47](https://user-images.githubusercontent.com/3050060/129728925-14aec500-82ff-4336-955a-4173c769deeb.png) ![Screenshot from 2021-08-17 14-49-52](https://user-images.githubusercontent.com/3050060/129728927-a8a89d7a-e837-4ff5-b094-35be23629d14.png) The idea is to not disturb the reading while telling the reader "you can click on this one", which is why it's not a text decoration. What do you think `@rust-lang/rustdoc` ? r? `@Nemo157`
2021-08-18Fix anchors display in rustdocGuillaume Gomez-5/+9
2021-08-17Add background-color on clickable definitions in source codeGuillaume Gomez-0/+9
2021-08-16Rollup merge of #87178 - moxian:rd-use, r=jyn514Mara Bos-4/+3
[rustdoc] Copy only item path to clipboard rather than full `use` statement. The (somewhat) recent addition of the "copy item import to clipboard" button is extremely nice. However, i tend to write my code with fully qualified paths wherever feasible and only resort to `use` statements as a refactoring pass. This makes the "copy to clipboard" workflow awkward to use, as i would be copy-pasting that as, say ```rust impl use std::ops::Add; for MyType { ``` and then go back and remove the `use ` and `;`. This PR removes the `use ;` decorations, making it much nicer to use for fully-qualified items. I argue, however, that this does not noticeably degrade experience for those who prefer to import items, since the hard part about those is getting the path right, and writing the `use ;` decoration can be done by hand with little effort.
2021-08-12Updates favicon order of precedence as it matters to Chromeskim-2/+2
2021-08-08Fix heading colours in Ayu themeKlim Tsoutsman-1/+1
Closes #87828 The issue seems to stem from #87210 where code headings were changed from a heading containing code to a heading with the `code-header` class. `rustdoc.css` was updated, but `ayu.css` was missed.
2021-08-06Add test for union keyword highlightingGuillaume Gomez-0/+26