diff options
| author | Alex Macleod <alex@macleod.io> | 2025-08-05 10:35:28 +0000 |
|---|---|---|
| committer | Alex Macleod <alex@macleod.io> | 2025-08-05 11:40:05 +0000 |
| commit | 0ea413fe6b6acd4b30e5e96ffe6d73882b22e8b7 (patch) | |
| tree | 1330a29bfbf0c43546e5e61d8150e7b6d233a32d | |
| parent | 7a179313b96cc9fe9d83218890085494b74f92f6 (diff) | |
| download | rust-0ea413fe6b6acd4b30e5e96ffe6d73882b22e8b7.tar.gz rust-0ea413fe6b6acd4b30e5e96ffe6d73882b22e8b7.zip | |
Generate lint count in template
| -rw-r--r-- | tests/compile-test.rs | 8 | ||||
| -rw-r--r-- | util/gh-pages/index_template.html | 2 | ||||
| -rw-r--r-- | util/gh-pages/script.js | 12 |
3 files changed, 8 insertions, 14 deletions
diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 664a748ee21..6b6dfd7b81e 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -433,6 +433,7 @@ fn ui_cargo_toml_metadata() { #[derive(Template)] #[template(path = "index_template.html")] struct Renderer<'a> { + count: usize, lints: &'a Vec<LintMetadata>, } @@ -512,7 +513,12 @@ impl DiagnosticCollector { fs::write( "util/gh-pages/index.html", - Renderer { lints: &metadata }.render().unwrap(), + Renderer { + count: LINTS.len(), + lints: &metadata, + } + .render() + .unwrap(), ) .unwrap(); }); diff --git a/util/gh-pages/index_template.html b/util/gh-pages/index_template.html index 5d65ea585df..327ccf6439e 100644 --- a/util/gh-pages/index_template.html +++ b/util/gh-pages/index_template.html @@ -49,7 +49,7 @@ Otherwise, have a great day =^.^= <script src="theme.js"></script> {# #} <div class="container"> {# #} - <h1 class="page-header">Clippy Lints <span id="lint-count" class="badge"></span></h1> {# #} + <h1 class="page-header">Clippy Lints <span class="badge">Total number: {{+ count }}</span></h1> {# #} <noscript> {# #} <div class="alert alert-danger" role="alert"> {# #} diff --git a/util/gh-pages/script.js b/util/gh-pages/script.js index d3204967531..d4b95d08df0 100644 --- a/util/gh-pages/script.js +++ b/util/gh-pages/script.js @@ -592,20 +592,8 @@ disableShortcutsButton.checked = disableShortcuts; addListeners(); highlightLazily(); - -function updateLintCount() { - const allLints = filters.getAllLints().filter(lint => lint.group != "deprecated"); - const totalLints = allLints.length; - - const countElement = document.getElementById("lint-count"); - if (countElement) { - countElement.innerText = `Total number: ${totalLints}`; - } -} - generateSettings(); generateSearch(); parseURLFilters(); scrollToLintByURL(); filters.filterLints(); -updateLintCount(); |
