Improve rendering speed by moving settings generation after theme rendering
This commit is contained in:
parent
e0b0851ba8
commit
47f40d468a
@ -9,7 +9,8 @@
|
||||
use clippy_lints::declared_lints::LINTS;
|
||||
use clippy_lints::deprecated_lints::{DEPRECATED, DEPRECATED_VERSION, RENAMED};
|
||||
use pulldown_cmark::{Options, Parser, html};
|
||||
use rinja::{Template, filters::Safe};
|
||||
use rinja::Template;
|
||||
use rinja::filters::Safe;
|
||||
use serde::Deserialize;
|
||||
use test_utils::IS_RUSTC_TEST_SUITE;
|
||||
use ui_test::custom_flags::Flag;
|
||||
@ -394,7 +395,7 @@ struct Renderer<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Renderer<'a> {
|
||||
fn markdown(&self, input: &str) -> Safe<String> {
|
||||
fn markdown(input: &str) -> Safe<String> {
|
||||
let parser = Parser::new_ext(input, Options::all());
|
||||
let mut html_output = String::new();
|
||||
html::push_html(&mut html_output, parser);
|
||||
@ -465,7 +466,11 @@ fn spawn() -> (Self, thread::JoinHandle<()>) {
|
||||
.collect();
|
||||
metadata.sort_unstable_by(|a, b| a.id.cmp(&b.id));
|
||||
|
||||
fs::write("util/gh-pages/index.html", Renderer { lints: &metadata }.render().unwrap()).unwrap();
|
||||
fs::write(
|
||||
"util/gh-pages/index.html",
|
||||
Renderer { lints: &metadata }.render().unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
});
|
||||
|
||||
(Self { sender }, handle)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Welcome to a Clippy's lint list, at least the source code of it. If you are
|
||||
interested in contributing to this website checkout `util/gh-pages/index.html`
|
||||
interested in contributing to this website checkout `util/gh-pages/index_template.html`
|
||||
inside the rust-clippy repository.
|
||||
|
||||
Otherwise, have a great day =^.^=
|
||||
@ -164,7 +164,7 @@ Otherwise, have a great day =^.^=
|
||||
</header>
|
||||
|
||||
<div class="list-group lint-docs">
|
||||
<div class="list-group-item lint-doc-md">{(markdown(lint.docs))}</div>
|
||||
<div class="list-group-item lint-doc-md">{(Self::markdown(lint.docs))}</div>
|
||||
<div class="lint-additional-info-container">
|
||||
{# Applicability #}
|
||||
<div class="lint-additional-info-item">
|
||||
|
@ -46,17 +46,6 @@ function setTheme(theme, store) {
|
||||
}
|
||||
}
|
||||
|
||||
// loading the theme after the initial load
|
||||
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
const theme = loadValue('theme');
|
||||
if (prefersDark.matches && !theme) {
|
||||
setTheme("coal", false);
|
||||
} else {
|
||||
setTheme(theme, false);
|
||||
}
|
||||
let disableShortcuts = loadValue('disable-shortcuts') === "true";
|
||||
document.getElementById("disable-shortcuts").checked = disableShortcuts;
|
||||
|
||||
window.searchState = {
|
||||
timeout: null,
|
||||
inputElem: document.getElementById("search-input"),
|
||||
@ -161,9 +150,6 @@ function handleShortcut(ev) {
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("keypress", handleShortcut);
|
||||
document.addEventListener("keydown", handleShortcut);
|
||||
|
||||
function toggleElements(filter, value) {
|
||||
let needsUpdate = false;
|
||||
let count = 0;
|
||||
@ -271,13 +257,13 @@ const GROUPS_FILTER_DEFAULT = {
|
||||
cargo: true,
|
||||
complexity: true,
|
||||
correctness: true,
|
||||
deprecated: false,
|
||||
nursery: true,
|
||||
pedantic: true,
|
||||
perf: true,
|
||||
restriction: true,
|
||||
style: true,
|
||||
suspicious: true,
|
||||
deprecated: false,
|
||||
};
|
||||
const LEVEL_FILTERS_DEFAULT = {
|
||||
allow: true,
|
||||
@ -287,7 +273,6 @@ const LEVEL_FILTERS_DEFAULT = {
|
||||
};
|
||||
const APPLICABILITIES_FILTER_DEFAULT = {
|
||||
Unspecified: true,
|
||||
Unresolved: true,
|
||||
MachineApplicable: true,
|
||||
MaybeIncorrect: true,
|
||||
HasPlaceholders: true,
|
||||
@ -570,9 +555,6 @@ function generateSearch() {
|
||||
searchState.inputElem.addEventListener("paste", handleInputChanged);
|
||||
}
|
||||
|
||||
generateSettings();
|
||||
generateSearch();
|
||||
|
||||
function scrollToLint(lintId) {
|
||||
const target = document.getElementById(lintId);
|
||||
if (!target) {
|
||||
@ -617,7 +599,28 @@ function parseURLFilters() {
|
||||
}
|
||||
}
|
||||
|
||||
// loading the theme after the initial load
|
||||
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
const theme = loadValue('theme');
|
||||
if (prefersDark.matches && !theme) {
|
||||
setTheme("coal", false);
|
||||
} else {
|
||||
setTheme(theme, false);
|
||||
}
|
||||
|
||||
let disableShortcuts = loadValue('disable-shortcuts') === "true";
|
||||
// To prevent having a "flash", we give back time to the web browser to finish rendering with
|
||||
// theme applied before finishing the rendering.
|
||||
setTimeout(() => {
|
||||
document.getElementById("disable-shortcuts").checked = disableShortcuts;
|
||||
|
||||
document.addEventListener("keypress", handleShortcut);
|
||||
document.addEventListener("keydown", handleShortcut);
|
||||
|
||||
generateSettings();
|
||||
generateSearch();
|
||||
parseURLFilters();
|
||||
scrollToLintByURL();
|
||||
filters.filterLints();
|
||||
onEachLazy(document.querySelectorAll("pre > code.language-rust"), el => hljs.highlightElement(el));
|
||||
}, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user