Skip to content

Commit cfbf7be

Browse files
authored
Rollup merge of #99904 - GuillaumeGomez:cleanup-html-whitespace, r=notriddle
Cleanup html whitespace I realized while looking at the raw HTML that we generated some unwanted white space characters. This PR cleans up the one coming directly from rustdoc. I'll check from `pulldown-cmark` for the remaining ones. Some numbers now: the difference is small, it goes from `63009` to `62859`. But multiplied by the number of files, it becomes quite interesting overall. r? `@notriddle`
2 parents 735969e + 6149cf9 commit cfbf7be

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

src/librustdoc/html/render/print_item.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
311311
w,
312312
"<h2 id=\"{id}\" class=\"small-section-header\">\
313313
<a href=\"#{id}\">{name}</a>\
314-
</h2>\n{}",
314+
</h2>{}",
315315
ITEM_TABLE_OPEN,
316316
id = cx.derive_id(my_section.id().to_owned()),
317317
name = my_section.name(),
@@ -415,10 +415,10 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
415415
write!(
416416
w,
417417
"<div class=\"item-left {stab}{add}module-item\">\
418-
<a class=\"{class}\" href=\"{href}\" title=\"{title}\">{name}</a>\
419-
{visibility_emoji}\
420-
{unsafety_flag}\
421-
{stab_tags}\
418+
<a class=\"{class}\" href=\"{href}\" title=\"{title}\">{name}</a>\
419+
{visibility_emoji}\
420+
{unsafety_flag}\
421+
{stab_tags}\
422422
</div>\
423423
<div class=\"item-right docblock-short\">{docs}</div>",
424424
name = myitem.name.unwrap(),
@@ -1126,7 +1126,8 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
11261126
write!(
11271127
w,
11281128
"<h2 id=\"fields\" class=\"fields small-section-header\">\
1129-
Fields<a href=\"#fields\" class=\"anchor\"></a></h2>"
1129+
Fields<a href=\"#fields\" class=\"anchor\"></a>\
1130+
</h2>"
11301131
);
11311132
for (field, ty) in fields {
11321133
let name = field.name.expect("union field name");
@@ -1238,7 +1239,8 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
12381239
write!(
12391240
w,
12401241
"<h2 id=\"variants\" class=\"variants small-section-header\">\
1241-
Variants{}<a href=\"#variants\" class=\"anchor\"></a></h2>",
1242+
Variants{}<a href=\"#variants\" class=\"anchor\"></a>\
1243+
</h2>",
12421244
document_non_exhaustive_header(it)
12431245
);
12441246
document_non_exhaustive(w, it);
@@ -1294,9 +1296,9 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
12941296
w,
12951297
"<div class=\"sub-variant-field\">\
12961298
<span id=\"{id}\" class=\"variant small-section-header\">\
1297-
<a href=\"#{id}\" class=\"anchor field\"></a>\
1298-
<code>{f}:&nbsp;{t}</code>\
1299-
</span>",
1299+
<a href=\"#{id}\" class=\"anchor field\"></a>\
1300+
<code>{f}:&nbsp;{t}</code>\
1301+
</span>",
13001302
id = id,
13011303
f = field.name.unwrap(),
13021304
t = ty.print(cx)

src/librustdoc/html/templates/page.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@
8282
{%- else -%}
8383
<img class="rust-logo" src="{{static_root_path|safe}}rust-logo{{page.resource_suffix}}.svg" alt="logo"> {#- -#}
8484
{%- endif -%}
85-
</div>
85+
</div> {#- -#}
8686
</a> {#- -#}
87-
<h2 class="location"></h2>
88-
</nav>
87+
<h2 class="location"></h2> {#- -#}
88+
</nav> {#- -#}
8989
<nav class="sidebar"> {#- -#}
9090
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
9191
<div class="logo-container"> {#- -#}
@@ -94,7 +94,7 @@ <h2 class="location"></h2>
9494
{%- else -%}
9595
<img class="rust-logo" src="{{static_root_path|safe}}rust-logo{{page.resource_suffix}}.svg" alt="logo"> {#- -#}
9696
{%- endif -%}
97-
</div>
97+
</div> {#- -#}
9898
</a> {#- -#}
9999
{{- sidebar|safe -}}
100100
</nav> {#- -#}
@@ -122,12 +122,12 @@ <h2 class="location"></h2>
122122
<div id="help-button" title="help" tabindex="-1"> {#- -#}
123123
<button type="button">?</button> {#- -#}
124124
</div> {#- -#}
125-
<div id="settings-menu" tabindex="-1">
125+
<div id="settings-menu" tabindex="-1"> {#- -#}
126126
<a href="{{page.root_path|safe}}settings.html" title="settings"> {#- -#}
127127
<img width="22" height="22" alt="Change settings" {# -#}
128128
src="{{static_root_path|safe}}wheel{{page.resource_suffix}}.svg"> {#- -#}
129129
</a> {#- -#}
130-
</div>
130+
</div> {#- -#}
131131
</div> {#- -#}
132132
</form> {#- -#}
133133
</nav> {#- -#}
@@ -143,6 +143,6 @@ <h2 class="location"></h2>
143143
data-resource-suffix="{{page.resource_suffix}}" {# -#}
144144
data-rustdoc-version="{{rustdoc_version}}" {# -#}
145145
> {#- -#}
146-
</div>
146+
</div> {#- -#}
147147
</body> {#- -#}
148148
</html> {#- -#}

src/librustdoc/html/templates/print_item.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="main-heading">
1+
<div class="main-heading"> {#- -#}
22
<h1 class="fqn"> {#- -#}
33
<span class="in-band"> {#- -#}
44
{{-typ-}}
@@ -27,4 +27,4 @@ <h1 class="fqn"> {#- -#}
2727
[<span class="inner">&#x2212;</span>] {#- -#}
2828
</a> {#- -#}
2929
</span> {#- -#}
30-
</div>
30+
</div> {#- -#}

0 commit comments

Comments
 (0)