-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`
- Loading branch information
Showing
12 changed files
with
216 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<span class="example"><span class="kw">let</span> <span class="ident">x</span> = <span class="number">1</span>;</span> | ||
<span class="kw">let</span> <span class="ident">y</span> = <span class="number">2</span>; | ||
<span class="example"><span class="kw">let </span>x = <span class="number">1</span>;</span> | ||
<span class="kw">let </span>y = <span class="number">2</span>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<span class="kw">pub</span> <span class="kw">fn</span> <span class="ident">foo</span>() { | ||
<span class="kw">pub fn </span>foo() { | ||
<span class="macro">println!</span>(<span class="string">"foo"</span>); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<span class="kw">use</span> <span class="ident"><span class="kw">crate</span>::a::foo</span>; | ||
<span class="kw">use</span> <span class="ident"><span class="self">self</span>::whatever</span>; | ||
<span class="kw">let</span> <span class="ident">x</span> = <span class="ident"><span class="kw">super</span>::b::foo</span>; | ||
<span class="kw">let</span> <span class="ident">y</span> = <span class="ident"><span class="self">Self</span>::whatever</span>; | ||
<span class="kw">use </span><span class="kw">crate</span>::a::foo; | ||
<span class="kw">use </span><span class="self">self</span>::whatever; | ||
<span class="kw">let </span>x = <span class="kw">super</span>::b::foo; | ||
<span class="kw">let </span>y = <span class="self">Self</span>::whatever; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<span class="kw">union</span> <span class="ident">Foo</span> { | ||
<span class="ident">i</span>: <span class="ident">i8</span>, | ||
<span class="ident">u</span>: <span class="ident">i8</span>, | ||
<span class="kw">union </span>Foo { | ||
i: i8, | ||
u: i8, | ||
} | ||
|
||
<span class="kw">fn</span> <span class="ident">main</span>() { | ||
<span class="kw">let</span> <span class="ident">union</span> = <span class="number">0</span>; | ||
<span class="kw">fn </span>main() { | ||
<span class="kw">let </span>union = <span class="number">0</span>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.