1
Fork 0

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`
This commit is contained in:
Yuki Okushi 2022-07-30 07:39:56 +09:00 committed by GitHub
commit cfbf7be7d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 19 deletions

View file

@ -311,7 +311,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
w, w,
"<h2 id=\"{id}\" class=\"small-section-header\">\ "<h2 id=\"{id}\" class=\"small-section-header\">\
<a href=\"#{id}\">{name}</a>\ <a href=\"#{id}\">{name}</a>\
</h2>\n{}", </h2>{}",
ITEM_TABLE_OPEN, ITEM_TABLE_OPEN,
id = cx.derive_id(my_section.id().to_owned()), id = cx.derive_id(my_section.id().to_owned()),
name = my_section.name(), name = my_section.name(),
@ -415,10 +415,10 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
write!( write!(
w, w,
"<div class=\"item-left {stab}{add}module-item\">\ "<div class=\"item-left {stab}{add}module-item\">\
<a class=\"{class}\" href=\"{href}\" title=\"{title}\">{name}</a>\ <a class=\"{class}\" href=\"{href}\" title=\"{title}\">{name}</a>\
{visibility_emoji}\ {visibility_emoji}\
{unsafety_flag}\ {unsafety_flag}\
{stab_tags}\ {stab_tags}\
</div>\ </div>\
<div class=\"item-right docblock-short\">{docs}</div>", <div class=\"item-right docblock-short\">{docs}</div>",
name = myitem.name.unwrap(), name = myitem.name.unwrap(),
@ -1126,7 +1126,8 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
write!( write!(
w, w,
"<h2 id=\"fields\" class=\"fields small-section-header\">\ "<h2 id=\"fields\" class=\"fields small-section-header\">\
Fields<a href=\"#fields\" class=\"anchor\"></a></h2>" Fields<a href=\"#fields\" class=\"anchor\"></a>\
</h2>"
); );
for (field, ty) in fields { for (field, ty) in fields {
let name = field.name.expect("union field name"); 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::
write!( write!(
w, w,
"<h2 id=\"variants\" class=\"variants small-section-header\">\ "<h2 id=\"variants\" class=\"variants small-section-header\">\
Variants{}<a href=\"#variants\" class=\"anchor\"></a></h2>", Variants{}<a href=\"#variants\" class=\"anchor\"></a>\
</h2>",
document_non_exhaustive_header(it) document_non_exhaustive_header(it)
); );
document_non_exhaustive(w, it); document_non_exhaustive(w, it);
@ -1294,9 +1296,9 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean::
w, w,
"<div class=\"sub-variant-field\">\ "<div class=\"sub-variant-field\">\
<span id=\"{id}\" class=\"variant small-section-header\">\ <span id=\"{id}\" class=\"variant small-section-header\">\
<a href=\"#{id}\" class=\"anchor field\"></a>\ <a href=\"#{id}\" class=\"anchor field\"></a>\
<code>{f}:&nbsp;{t}</code>\ <code>{f}:&nbsp;{t}</code>\
</span>", </span>",
id = id, id = id,
f = field.name.unwrap(), f = field.name.unwrap(),
t = ty.print(cx) t = ty.print(cx)

View file

@ -82,10 +82,10 @@
{%- else -%} {%- else -%}
<img class="rust-logo" src="{{static_root_path|safe}}rust-logo{{page.resource_suffix}}.svg" alt="logo"> {#- -#} <img class="rust-logo" src="{{static_root_path|safe}}rust-logo{{page.resource_suffix}}.svg" alt="logo"> {#- -#}
{%- endif -%} {%- endif -%}
</div> </div> {#- -#}
</a> {#- -#} </a> {#- -#}
<h2 class="location"></h2> <h2 class="location"></h2> {#- -#}
</nav> </nav> {#- -#}
<nav class="sidebar"> {#- -#} <nav class="sidebar"> {#- -#}
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#} <a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
<div class="logo-container"> {#- -#} <div class="logo-container"> {#- -#}
@ -94,7 +94,7 @@
{%- else -%} {%- else -%}
<img class="rust-logo" src="{{static_root_path|safe}}rust-logo{{page.resource_suffix}}.svg" alt="logo"> {#- -#} <img class="rust-logo" src="{{static_root_path|safe}}rust-logo{{page.resource_suffix}}.svg" alt="logo"> {#- -#}
{%- endif -%} {%- endif -%}
</div> </div> {#- -#}
</a> {#- -#} </a> {#- -#}
{{- sidebar|safe -}} {{- sidebar|safe -}}
</nav> {#- -#} </nav> {#- -#}
@ -122,12 +122,12 @@
<div id="help-button" title="help" tabindex="-1"> {#- -#} <div id="help-button" title="help" tabindex="-1"> {#- -#}
<button type="button">?</button> {#- -#} <button type="button">?</button> {#- -#}
</div> {#- -#} </div> {#- -#}
<div id="settings-menu" tabindex="-1"> <div id="settings-menu" tabindex="-1"> {#- -#}
<a href="{{page.root_path|safe}}settings.html" title="settings"> {#- -#} <a href="{{page.root_path|safe}}settings.html" title="settings"> {#- -#}
<img width="22" height="22" alt="Change settings" {# -#} <img width="22" height="22" alt="Change settings" {# -#}
src="{{static_root_path|safe}}wheel{{page.resource_suffix}}.svg"> {#- -#} src="{{static_root_path|safe}}wheel{{page.resource_suffix}}.svg"> {#- -#}
</a> {#- -#} </a> {#- -#}
</div> </div> {#- -#}
</div> {#- -#} </div> {#- -#}
</form> {#- -#} </form> {#- -#}
</nav> {#- -#} </nav> {#- -#}
@ -143,6 +143,6 @@
data-resource-suffix="{{page.resource_suffix}}" {# -#} data-resource-suffix="{{page.resource_suffix}}" {# -#}
data-rustdoc-version="{{rustdoc_version}}" {# -#} data-rustdoc-version="{{rustdoc_version}}" {# -#}
> {#- -#} > {#- -#}
</div> </div> {#- -#}
</body> {#- -#} </body> {#- -#}
</html> {#- -#} </html> {#- -#}

View file

@ -1,4 +1,4 @@
<div class="main-heading"> <div class="main-heading"> {#- -#}
<h1 class="fqn"> {#- -#} <h1 class="fqn"> {#- -#}
<span class="in-band"> {#- -#} <span class="in-band"> {#- -#}
{{-typ-}} {{-typ-}}
@ -27,4 +27,4 @@
[<span class="inner">&#x2212;</span>] {#- -#} [<span class="inner">&#x2212;</span>] {#- -#}
</a> {#- -#} </a> {#- -#}
</span> {#- -#} </span> {#- -#}
</div> </div> {#- -#}