]> git.lizzy.rs Git - rust.git/commit
Auto merge of #100429 - GuillaumeGomez:merge-html-elements-together, r=notriddle
authorbors <bors@rust-lang.org>
Sun, 14 Aug 2022 14:37:17 +0000 (14:37 +0000)
committerbors <bors@rust-lang.org>
Sun, 14 Aug 2022 14:37:17 +0000 (14:37 +0000)
commit801821d1560f84e4716fcbd9244ec959320a13d5
tree18e83946f4f278cdc83845f0f79676b464644b5e
parent4c5665583815a0f0f3e22516441efb43ea6dede2
parent6e574e100c47d1800e05d14cbaae959c11f320ed
Auto merge of #100429 - GuillaumeGomez:merge-html-elements-together, r=notriddle

rustdoc: Merge source code pages HTML elements together

We realized that the HTML generated for the source code pages could be improved quite a lot. This PR is a first pass toward this goal. Some explanations: it merges similar classes elements (even when there are white characters in between).

There is an exception to this: if this is an ident, I also merged it with "unclassified" elements. This part is up to debate and can be very easily removed as the check is performed in one place (in the `can_merge` function).

EDIT: The `ident` is now only kept in the code for the `span` it contains but it is not rendered into the HTML.

So now some numbers:

For these ones, on each page, I run this JS: `document.getElementsByTagName('*').length`. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others.

| file name | before this PR | with this PR | diff | without ident | diff |
|-|-|-|-|-|-|
| std/lib.rs.html (source link on std crate page) | 3455 | 2776 | 20.7% | 2387 | 31% |
| alloc/vec/mod.rs.html (source on Vec type page) | 11012 | 8084 | 26.6% | 6682 | 39.4% |
| alloc/string.rs.html (source on String type page) | 10800 | 8214 | 24% | 6712 | 37.9% |
| std/sync/mutex.rs.html (source on Mutex type page) | 2953 | 2403 | 18.7% | 2139 | 27.6% |

You can test it [here](https://rustdoc.crud.net/imperio/merge-html-elements-together/src/std/lib.rs.html).

cc `@jsha`
r? `@notriddle`