Skip to content

rustdoc: Merge source code pages HTML elements together#100429

Merged
bors merged 3 commits intorust-lang:masterfrom
GuillaumeGomez:merge-html-elements-together
Aug 14, 2022
Merged

rustdoc: Merge source code pages HTML elements together#100429
bors merged 3 commits intorust-lang:masterfrom
GuillaumeGomez:merge-html-elements-together

Conversation

@GuillaumeGomez
Copy link
Copy Markdown
Member

@GuillaumeGomez GuillaumeGomez commented Aug 11, 2022

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.

cc @jsha
r? @notriddle

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-ui Area: Rustdoc UI (generated HTML) merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants