Skip to content

Commit b98252f

Browse files
Generate lint count in template (#15414)
Removes the pop-in of the element on page load changelog: none
2 parents 264bc97 + 0ea413f commit b98252f

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

tests/compile-test.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ fn ui_cargo_toml_metadata() {
433433
#[derive(Template)]
434434
#[template(path = "index_template.html")]
435435
struct Renderer<'a> {
436+
count: usize,
436437
lints: &'a Vec<LintMetadata>,
437438
}
438439

@@ -512,7 +513,12 @@ impl DiagnosticCollector {
512513

513514
fs::write(
514515
"util/gh-pages/index.html",
515-
Renderer { lints: &metadata }.render().unwrap(),
516+
Renderer {
517+
count: LINTS.len(),
518+
lints: &metadata,
519+
}
520+
.render()
521+
.unwrap(),
516522
)
517523
.unwrap();
518524
});

util/gh-pages/index_template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<script src="theme.js"></script> {# #}
5050

5151
<div class="container"> {# #}
52-
<h1 class="page-header">Clippy Lints <span id="lint-count" class="badge"></span></h1> {# #}
52+
<h1 class="page-header">Clippy Lints <span class="badge">Total number: {{+ count }}</span></h1> {# #}
5353

5454
<noscript> {# #}
5555
<div class="alert alert-danger" role="alert"> {# #}

util/gh-pages/script.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -593,20 +593,8 @@ disableShortcutsButton.checked = disableShortcuts;
593593

594594
addListeners();
595595
highlightLazily();
596-
597-
function updateLintCount() {
598-
const allLints = filters.getAllLints().filter(lint => lint.group != "deprecated");
599-
const totalLints = allLints.length;
600-
601-
const countElement = document.getElementById("lint-count");
602-
if (countElement) {
603-
countElement.innerText = `Total number: ${totalLints}`;
604-
}
605-
}
606-
607596
generateSettings();
608597
generateSearch();
609598
parseURLFilters();
610599
scrollToLintByURL();
611600
filters.filterLints();
612-
updateLintCount();

0 commit comments

Comments
 (0)