Skip to content

Commit e2270bb

Browse files
Reduce clippy lints page size (#15235)
Follow-up of #15208. Removed some unneeded wrappings and shortened some CSS class name. The diff is big because of one indent level getting removed. :-/ Before this PR: 1751301 With this PR: 1663634 Reduction: -5% r? @samueltardieu changelog: Reduce page size and number of DOM elements on clippy lints page
2 parents 488f4dd + b1d1762 commit e2270bb

File tree

3 files changed

+181
-179
lines changed

3 files changed

+181
-179
lines changed

util/gh-pages/index_template.html

Lines changed: 123 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -49,153 +49,149 @@
4949
<script src="theme.js"></script> {# #}
5050

5151
<div class="container"> {# #}
52-
<div class="page-header"> {# #}
53-
<h1>Clippy Lints <span id="lint-count" class="badge"></span></h1> {# #}
54-
</div> {# #}
52+
<h1 class="page-header">Clippy Lints <span id="lint-count" class="badge"></span></h1> {# #}
5553

5654
<noscript> {# #}
5755
<div class="alert alert-danger" role="alert"> {# #}
5856
Lints search and filtering only works with JS enabled. :( {# #}
5957
</div> {# #}
6058
</noscript> {# #}
6159

62-
<div> {# #}
63-
<div class="panel panel-default" id="menu-filters"> {# #}
64-
<div class="panel-body row"> {# #}
65-
<div id="upper-filters" class="col-12 col-md-5"> {# #}
66-
<div class="btn-group" id="lint-levels" tabindex="-1"> {# #}
67-
<button type="button" class="btn btn-default dropdown-toggle"> {# #}
68-
Lint levels <span class="badge">4</span> <span class="caret"></span> {# #}
69-
</button> {# #}
70-
<ul class="dropdown-menu" id="lint-levels-selector"> {# #}
71-
<li class="checkbox"> {# #}
72-
<button onclick="toggleElements('levels_filter', true)">All</button> {# #}
73-
</li> {# #}
74-
<li class="checkbox"> {# #}
75-
<button onclick="toggleElements('levels_filter', false)">None</button> {# #}
76-
</li> {# #}
77-
<li role="separator" class="divider"></li> {# #}
78-
</ul> {# #}
79-
</div> {# #}
80-
<div class="btn-group" id="lint-groups" tabindex="-1"> {# #}
81-
<button type="button" class="btn btn-default dropdown-toggle"> {# #}
82-
Lint groups <span class="badge">9</span> <span class="caret"></span> {# #}
83-
</button> {# #}
84-
<ul class="dropdown-menu" id="lint-groups-selector"> {# #}
85-
<li class="checkbox"> {# #}
86-
<button onclick="toggleElements('groups_filter', true)">All</button> {# #}
87-
</li> {# #}
88-
<li class="checkbox"> {# #}
89-
<button onclick="resetGroupsToDefault()">Default</button> {# #}
90-
</li> {# #}
91-
<li class="checkbox"> {# #}
92-
<button onclick="toggleElements('groups_filter', false)">None</button> {# #}
93-
</li> {# #}
94-
<li role="separator" class="divider"></li> {# #}
95-
</ul> {# #}
96-
</div> {# #}
97-
<div class="btn-group" id="version-filter" tabindex="-1"> {# #}
98-
<button type="button" class="btn btn-default dropdown-toggle"> {# #}
99-
Version {#+ #}
100-
<span id="version-filter-count" class="badge">0</span> {#+ #}
101-
<span class="caret"></span> {# #}
102-
</button> {# #}
103-
<ul id="version-filter-selector" class="dropdown-menu"> {# #}
104-
<li class="checkbox"> {# #}
105-
<button onclick="clearVersionFilters()">Clear filters</button> {# #}
106-
</li> {# #}
107-
<li role="separator" class="divider"></li> {# #}
108-
</ul> {# #}
109-
</div> {# #}
110-
<div class="btn-group" id="lint-applicabilities" tabindex="-1"> {# #}
111-
<button type="button" class="btn btn-default dropdown-toggle"> {# #}
112-
Applicability {#+ #}
113-
<span class="badge">4</span> {#+ #}
114-
<span class="caret"></span> {# #}
115-
</button> {# #}
116-
<ul class="dropdown-menu" id="lint-applicabilities-selector"> {# #}
117-
<li class="checkbox"> {# #}
118-
<button onclick="toggleElements('applicabilities_filter', true)">All</button> {# #}
119-
</li> {# #}
120-
<li class="checkbox"> {# #}
121-
<button onclick="toggleElements('applicabilities_filter', false)">None</button> {# #}
122-
</li> {# #}
123-
<li role="separator" class="divider"></li> {# #}
124-
</ul> {# #}
125-
</div> {# #}
60+
<div id="menu-filters"> {# #}
61+
<div class="panel-body row"> {# #}
62+
<div id="upper-filters" class="col-12 col-md-5"> {# #}
63+
<div class="btn-group" id="lint-levels" tabindex="-1"> {# #}
64+
<button type="button" class="btn btn-default dropdown-toggle"> {# #}
65+
Lint levels <span class="badge">4</span> <span class="caret"></span> {# #}
66+
</button> {# #}
67+
<ul class="dropdown-menu" id="lint-levels-selector"> {# #}
68+
<li class="checkbox"> {# #}
69+
<button onclick="toggleElements('levels_filter', true)">All</button> {# #}
70+
</li> {# #}
71+
<li class="checkbox"> {# #}
72+
<button onclick="toggleElements('levels_filter', false)">None</button> {# #}
73+
</li> {# #}
74+
<li role="separator" class="divider"></li> {# #}
75+
</ul> {# #}
12676
</div> {# #}
127-
<div class="col-12 col-md-5 search-control"> {# #}
128-
<div class="input-group"> {# #}
129-
<label class="input-group-addon" id="filter-label" for="search-input">Filter:</label> {# #}
130-
<input type="text" class="form-control filter-input" placeholder="Keywords or search string (`S` or `/` to focus)" id="search-input" /> {# #}
131-
<span class="input-group-btn"> {# #}
132-
<button class="filter-clear btn" type="button" onclick="searchState.clearInput(event)"> {# #}
133-
Clear {# #}
134-
</button> {# #}
135-
</span> {# #}
136-
</div> {# #}
77+
<div class="btn-group" id="lint-groups" tabindex="-1"> {# #}
78+
<button type="button" class="btn btn-default dropdown-toggle"> {# #}
79+
Lint groups <span class="badge">9</span> <span class="caret"></span> {# #}
80+
</button> {# #}
81+
<ul class="dropdown-menu" id="lint-groups-selector"> {# #}
82+
<li class="checkbox"> {# #}
83+
<button onclick="toggleElements('groups_filter', true)">All</button> {# #}
84+
</li> {# #}
85+
<li class="checkbox"> {# #}
86+
<button onclick="resetGroupsToDefault()">Default</button> {# #}
87+
</li> {# #}
88+
<li class="checkbox"> {# #}
89+
<button onclick="toggleElements('groups_filter', false)">None</button> {# #}
90+
</li> {# #}
91+
<li role="separator" class="divider"></li> {# #}
92+
</ul> {# #}
13793
</div> {# #}
138-
<div class="col-12 col-md-2 btn-group expansion-group"> {# #}
139-
<button title="Collapse All" class="btn btn-default expansion-control" type="button" id="collapse-all"> {# #}
140-
<span class="glyphicon glyphicon-collapse-up"></span> {# #}
94+
<div class="btn-group" id="version-filter" tabindex="-1"> {# #}
95+
<button type="button" class="btn btn-default dropdown-toggle"> {# #}
96+
Version {#+ #}
97+
<span id="version-filter-count" class="badge">0</span> {#+ #}
98+
<span class="caret"></span> {# #}
14199
</button> {# #}
142-
<button title="Expand All" class="btn btn-default expansion-control" type="button" id="expand-all"> {# #}
143-
<span class="glyphicon glyphicon-collapse-down"></span> {# #}
100+
<ul id="version-filter-selector" class="dropdown-menu"> {# #}
101+
<li class="checkbox"> {# #}
102+
<button onclick="clearVersionFilters()">Clear filters</button> {# #}
103+
</li> {# #}
104+
<li role="separator" class="divider"></li> {# #}
105+
</ul> {# #}
106+
</div> {# #}
107+
<div class="btn-group" id="lint-applicabilities" tabindex="-1"> {# #}
108+
<button type="button" class="btn btn-default dropdown-toggle"> {# #}
109+
Applicability {#+ #}
110+
<span class="badge">4</span> {#+ #}
111+
<span class="caret"></span> {# #}
144112
</button> {# #}
113+
<ul class="dropdown-menu" id="lint-applicabilities-selector"> {# #}
114+
<li class="checkbox"> {# #}
115+
<button onclick="toggleElements('applicabilities_filter', true)">All</button> {# #}
116+
</li> {# #}
117+
<li class="checkbox"> {# #}
118+
<button onclick="toggleElements('applicabilities_filter', false)">None</button> {# #}
119+
</li> {# #}
120+
<li role="separator" class="divider"></li> {# #}
121+
</ul> {# #}
122+
</div> {# #}
123+
</div> {# #}
124+
<div class="col-12 col-md-5 search-control"> {# #}
125+
<div class="input-group"> {# #}
126+
<label class="input-group-addon" id="filter-label" for="search-input">Filter:</label> {# #}
127+
<input type="text" class="form-control filter-input" placeholder="Keywords or search string (`S` or `/` to focus)" id="search-input" /> {# #}
128+
<span class="input-group-btn"> {# #}
129+
<button class="filter-clear btn" type="button" onclick="searchState.clearInput(event)"> {# #}
130+
Clear {# #}
131+
</button> {# #}
132+
</span> {# #}
145133
</div> {# #}
146134
</div> {# #}
147-
</div>
148-
{% for lint in lints %}
149-
<article class="panel panel-default" id="{{lint.id}}"> {# #}
150-
<input id="label-{{lint.id}}" type="checkbox"> {# #}
151-
<label for="label-{{lint.id}}"> {# #}
152-
<h2 class="lint-title"> {# #}
153-
<div class="panel-title-name" id="lint-{{lint.id}}"> {# #}
154-
{{lint.id +}}
155-
<a href="#{{lint.id}}" class="anchor label label-default">&para;</a> {#+ #}
156-
<a href="" class="copy-to-clipboard anchor label label-default"> {# #}
157-
&#128203; {# #}
158-
</a> {# #}
159-
</div> {# #}
135+
<div class="col-12 col-md-2 btn-group expansion-group"> {# #}
136+
<button title="Collapse All" class="btn btn-default expansion-control" type="button" id="collapse-all"> {# #}
137+
<span class="glyphicon glyphicon-collapse-up"></span> {# #}
138+
</button> {# #}
139+
<button title="Expand All" class="btn btn-default expansion-control" type="button" id="expand-all"> {# #}
140+
<span class="glyphicon glyphicon-collapse-down"></span> {# #}
141+
</button> {# #}
142+
</div> {# #}
143+
</div> {# #}
144+
</div>
145+
{% for lint in lints %}
146+
<article id="{{lint.id}}"> {# #}
147+
<input id="label-{{lint.id}}" type="checkbox"> {# #}
148+
<label for="label-{{lint.id}}"> {# #}
149+
<h2 class="lint-title"> {# #}
150+
<div class="panel-title-name" id="lint-{{lint.id}}"> {# #}
151+
{{lint.id +}}
152+
<a href="#{{lint.id}}" class="anchor label label-default">&para;</a> {#+ #}
153+
<a href="" class="copy-to-clipboard anchor label label-default"> {# #}
154+
&#128203; {# #}
155+
</a> {# #}
156+
</div> {# #}
160157

161-
<span class="label label-lint-group label-default label-group-{{lint.group}}">{{lint.group}}</span> {#+ #}
158+
<span class="label label-default lint-group group-{{lint.group}}">{{lint.group}}</span> {#+ #}
162159

163-
<span class="label label-lint-level label-lint-level-{{lint.level}}">{{lint.level}}</span> {#+ #}
160+
<span class="label lint-level level-{{lint.level}}">{{lint.level}}</span> {#+ #}
164161

165-
<span class="label label-doc-folding"></span> {# #}
166-
</h2> {# #}
167-
</label> {# #}
162+
<span class="label doc-folding"></span> {# #}
163+
</h2> {# #}
164+
</label> {# #}
168165

169-
<div class="list-group lint-docs"> {# #}
170-
<div class="list-group-item lint-doc-md">{{Self::markdown(lint.docs)}}</div> {# #}
171-
<div class="lint-additional-info-container">
172-
{# Applicability #}
173-
<div> {# #}
174-
Applicability: {#+ #}
175-
<span class="label label-default label-applicability">{{ lint.applicability_str() }}</span> {# #}
176-
<a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.Applicability.html#variants">(?)</a> {# #}
177-
</div>
178-
{# Clippy version #}
179-
<div> {# #}
180-
{% if lint.group == "deprecated" %}Deprecated{% else %} Added{% endif +%} in: {#+ #}
181-
<span class="label label-default label-version">{{lint.version}}</span> {# #}
182-
</div>
183-
{# Open related issues #}
166+
<div class="lint-docs"> {# #}
167+
<div class="lint-doc-md">{{Self::markdown(lint.docs)}}</div> {# #}
168+
<div class="lint-additional-info">
169+
{# Applicability #}
170+
<div> {# #}
171+
Applicability: {#+ #}
172+
<span class="label label-default applicability">{{ lint.applicability_str() }}</span> {# #}
173+
<a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint_defs/enum.Applicability.html#variants">(?)</a> {# #}
174+
</div>
175+
{# Clippy version #}
176+
<div> {# #}
177+
{% if lint.group == "deprecated" %}Deprecated{% else %} Added{% endif +%} in: {#+ #}
178+
<span class="label label-default label-version">{{lint.version}}</span> {# #}
179+
</div>
180+
{# Open related issues #}
181+
<div> {# #}
182+
<a href="https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+{{lint.id}}">Related Issues</a> {# #}
183+
</div>
184+
185+
{# Jump to source #}
186+
{% if let Some(id_location) = lint.id_location %}
184187
<div> {# #}
185-
<a href="https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+{{lint.id}}">Related Issues</a> {# #}
188+
<a href="https://github.com/rust-lang/rust-clippy/blob/master/{{id_location}}">View Source</a> {# #}
186189
</div>
187-
188-
{# Jump to source #}
189-
{% if let Some(id_location) = lint.id_location %}
190-
<div> {# #}
191-
<a href="https://github.com/rust-lang/rust-clippy/blob/master/{{id_location}}">View Source</a> {# #}
192-
</div>
193-
{% endif %}
194-
</div> {# #}
190+
{% endif %}
195191
</div> {# #}
196-
</article>
197-
{% endfor %}
198-
</div> {# #}
192+
</div> {# #}
193+
</article>
194+
{% endfor %}
199195
</div> {# #}
200196

201197
<a {#+ #}

util/gh-pages/script.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ window.filters = {
250250
}
251251
return {
252252
elem: elem,
253-
group: elem.querySelector(".label-lint-group").innerText,
254-
level: elem.querySelector(".label-lint-level").innerText,
253+
group: elem.querySelector(".lint-group").innerText,
254+
level: elem.querySelector(".lint-level").innerText,
255255
version: parseInt(version.split(".")[1]),
256-
applicability: elem.querySelector(".label-applicability").innerText,
256+
applicability: elem.querySelector(".applicability").innerText,
257257
filteredOut: false,
258258
searchFilteredOut: false,
259259
};
@@ -594,19 +594,19 @@ disableShortcutsButton.checked = disableShortcuts;
594594
addListeners();
595595
highlightLazily();
596596

597-
generateSettings();
598-
generateSearch();
599-
parseURLFilters();
600-
scrollToLintByURL();
601-
filters.filterLints();
602-
updateLintCount();
603-
604597
function updateLintCount() {
605598
const allLints = filters.getAllLints().filter(lint => lint.group != "deprecated");
606599
const totalLints = allLints.length;
607-
600+
608601
const countElement = document.getElementById("lint-count");
609602
if (countElement) {
610603
countElement.innerText = `Total number: ${totalLints}`;
611604
}
612605
}
606+
607+
generateSettings();
608+
generateSearch();
609+
parseURLFilters();
610+
scrollToLintByURL();
611+
filters.filterLints();
612+
updateLintCount();

0 commit comments

Comments
 (0)