From 603934336dea3c8385f0c7a03ebf2ecebfe913a2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 29 Aug 2024 21:24:56 +0200 Subject: [PATCH] Greatly reduce generated HTML page size --- rinja.toml | 1 + tests/compile-test.rs | 2 +- util/gh-pages/index_template.html | 392 +++++++++++++++--------------- util/gh-pages/script.js | 23 +- util/gh-pages/style.css | 3 + 5 files changed, 207 insertions(+), 214 deletions(-) diff --git a/rinja.toml b/rinja.toml index 4f0a8afd2b5..a10da6e1f28 100644 --- a/rinja.toml +++ b/rinja.toml @@ -1,2 +1,3 @@ [general] dirs = ["util/gh-pages/"] +whitespace = "suppress" diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 162aed393c4..2589383208c 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -394,7 +394,7 @@ struct Renderer<'a> { lints: &'a Vec, } -impl<'a> Renderer<'a> { +impl Renderer<'_> { fn markdown(input: &str) -> Safe { let parser = Parser::new_ext(input, Options::all()); let mut html_output = String::new(); diff --git a/util/gh-pages/index_template.html b/util/gh-pages/index_template.html index 5045c601ad4..663ef1fbd31 100644 --- a/util/gh-pages/index_template.html +++ b/util/gh-pages/index_template.html @@ -6,227 +6,227 @@ inside the rust-clippy repository. Otherwise, have a great day =^.^= --> - - - - - + {# #} + {# #} + {# #} + {# #} + {# #} - Clippy Lints + Clippy Lints {# #} - - - + {# #} + {# #} + {# #} - - - - - - - - -
- -
-
Theme
- - -
-
+ {# #} + {# #} + {# #} + {# #} + {# #} + {# #} + {# #} + {# #} +
{# #} + {# #} +
{# #} +
Theme
{# #} + {# #} + {# #} +
{# #} +
{# #} -
- +
{# #} + {# #} - + {# #} -
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
- - - - - -
-
-
- - -
-
+
{# #} +
{# #} +
{# #} +
{# #} +
{# #} + {# #} + {# #} +
{# #} +
{# #} + {# #} + {# #} +
{# #} +
{# #} + {# #} + {# #} +
{# #} +
{# #} + {# #} + {# #} +
{# #} +
{# #} +
{# #} +
{# #} + {# #} + {# #} + {# #} + {# #} + {# #} +
{# #} +
{# #} +
{# #} + {# #} + {# #} +
{# #} +
{# #}
{% for lint in lints %} -
{# #} + {# #} + {# #} -
-
{{Self::markdown(lint.docs)}}
+
{# #} +
{{Self::markdown(lint.docs)}}
{# #}
{# Applicability #} -
- Applicability: - {{ lint.applicability_str() }} - (?) +
{# #} + Applicability: {# #} + {{ lint.applicability_str() }} {# #} + (?) {# #}
{# Clippy version #} -
- {% if lint.group == "deprecated" %}Deprecated{% else %} Added{% endif %} in: - {{lint.version}} +
{# #} + {% if lint.group == "deprecated" %}Deprecated{% else %} Added{% endif +%} in: {# #} + {{lint.version}} {# #}
{# Open related issues #} -
- Related Issues +
{# #} + Related Issues {# #}
{# Jump to source #} {% if let Some(id_location) = lint.id_location %} -
- View Source +
{# #} + View Source {# #} +
{% endif %} -
-
-
+
{# #} +
{# #} {% endfor %} -
-
+
{# #} +
{# #} - - - + {# #} + {# #} + {# #} - - - - - + {# #} + {# #} + {# #} + {# #} + {# #} diff --git a/util/gh-pages/script.js b/util/gh-pages/script.js index 7f36021e1aa..cc22a39b3d1 100644 --- a/util/gh-pages/script.js +++ b/util/gh-pages/script.js @@ -140,19 +140,15 @@ function onEachLazy(lazyArray, func) { function highlightIfNeeded(elem) { onEachLazy(elem.querySelectorAll("pre > code.language-rust:not(.highlighted)"), el => { - hljs.highlightElement(el) + hljs.highlightElement(el.parentElement) el.classList.add("highlighted"); }); } -function expandLintId(lintId) { - searchState.inputElem.value = lintId; - searchState.filterLints(); - - // Expand the lint. +function expandLint(lintId) { const lintElem = document.getElementById(lintId); - const isCollapsed = lintElem.classList.remove("collapsed"); - lintElem.querySelector(".label-doc-folding").innerText = "-"; + const isCollapsed = lintElem.classList.toggle("collapsed"); + lintElem.querySelector(".label-doc-folding").innerText = isCollapsed ? "+" : "−"; highlightIfNeeded(lintElem); } @@ -160,14 +156,7 @@ function expandLintId(lintId) { function openLint(event) { event.preventDefault(); event.stopPropagation(); - expandLintId(event.target.getAttribute("href").slice(1)); -} - -function expandLint(lintId) { - const lintElem = document.getElementById(lintId); - const isCollapsed = lintElem.classList.toggle("collapsed"); - lintElem.querySelector(".label-doc-folding").innerText = isCollapsed ? "+" : "-"; - highlightIfNeeded(lintElem); + expandLint(event.target.getAttribute("href").slice(1)); } function copyToClipboard(event) { @@ -526,7 +515,7 @@ function scrollToLint(lintId) { return; } target.scrollIntoView(); - expandLintId(lintId); + expandLint(lintId); } // If the page we arrive on has link to a given lint, we scroll to it. diff --git a/util/gh-pages/style.css b/util/gh-pages/style.css index 43c62642207..a68a10b1401 100644 --- a/util/gh-pages/style.css +++ b/util/gh-pages/style.css @@ -272,6 +272,9 @@ L4.75,12h2.5l0.5393066-2.1572876 c0.2276001-0.1062012,0.4459839-0.2269287,0.649 height: 18px; display: block; filter: invert(0.7); + position: absolute; + top: 4px; + left: 5px; } .settings-menu * {