Greatly improve rustdoc rendering speed issues

This commit is contained in:
Guillaume Gomez 2018-11-16 16:31:07 +01:00
parent 118e052d84
commit edfe2a893e
4 changed files with 611 additions and 529 deletions

View File

@ -868,9 +868,8 @@ fn write_shared(
}
{
let mut data = format!("var resourcesSuffix = \"{}\";\n",
cx.shared.resource_suffix);
data.push_str(static_files::STORAGE_JS);
let mut data = static_files::STORAGE_JS.to_owned();
data.push_str(&format!("var resourcesSuffix = \"{}\";", cx.shared.resource_suffix));
write_minify(cx.dst.join(&format!("storage{}.js", cx.shared.resource_suffix)),
&data,
options.enable_minification)?;

File diff suppressed because it is too large Load Diff

View File

@ -368,6 +368,10 @@ body:not(.source) .example-wrap > pre {
#main > .docblock h2 { font-size: 1.15em; }
#main > .docblock h3, #main > .docblock h4, #main > .docblock h5 { font-size: 1em; }
#main > h2 + div, #main > h2 + h3, #main > h3 + div {
display: none;
}
.docblock h1 { font-size: 1em; }
.docblock h2 { font-size: 0.95em; }
.docblock h3, .docblock h4, .docblock h5 { font-size: 0.9em; }

View File

@ -19,55 +19,44 @@ var mainTheme = document.getElementById("mainThemeStyle");
var savedHref = [];
function hasClass(elem, className) {
if (elem && className && elem.className) {
var elemClass = elem.className;
var start = elemClass.indexOf(className);
if (start === -1) {
return false;
} else if (elemClass.length === className.length) {
return true;
} else {
if (start > 0 && elemClass[start - 1] !== ' ') {
return false;
}
var end = start + className.length;
return !(end < elemClass.length && elemClass[end] !== ' ');
}
if (!elem || !elem.classList) {
return false;
}
return false;
return elem.classList.contains(className);
}
function addClass(elem, className) {
if (elem && className && !hasClass(elem, className)) {
if (elem.className && elem.className.length > 0) {
elem.className += ' ' + className;
} else {
elem.className = className;
}
if (!elem || !elem.classList) {
return;
}
elem.classList.add(className);
}
function removeClass(elem, className) {
if (elem && className && elem.className) {
elem.className = (" " + elem.className + " ").replace(" " + className + " ", " ")
.trim();
if (!elem || !elem.classList) {
return;
}
elem.classList.remove(className);
}
function isHidden(elem) {
return (elem.offsetParent === null)
return (elem.offsetParent === null);
}
var allcallers = {};
var resourcesSuffix="";
function onEach(arr, func, reversed) {
if (arr && arr.length > 0 && func) {
var length = arr.length;
if (reversed !== true) {
for (var i = 0; i < arr.length; ++i) {
for (var i = 0; i < length; ++i) {
if (func(arr[i]) === true) {
return true;
}
}
} else {
for (var i = arr.length - 1; i >= 0; --i) {
for (var i = length - 1; i >= 0; --i) {
if (func(arr[i]) === true) {
return true;
}
@ -133,8 +122,8 @@ function switchTheme(styleElem, mainStyleElem, newTheme) {
});
if (found === true) {
styleElem.href = newHref;
updateLocalStorage('rustdoc-theme', newTheme);
updateLocalStorage("rustdoc-theme", newTheme);
}
}
switchTheme(currentTheme, mainTheme, getCurrentValue('rustdoc-theme') || 'light');
switchTheme(currentTheme, mainTheme, getCurrentValue("rustdoc-theme") || "light");