Move search JS into search-index.js

Export a few variables and functions into the global scope because they
are needed both by main.js and search-index.js.
This commit is contained in:
Jacob Hoffman-Andrews 2021-04-11 22:19:29 -07:00
parent d4d7ebf142
commit 276ee6f542
4 changed files with 1534 additions and 1524 deletions

View File

@ -408,9 +408,8 @@ pub(super) fn write_shared(
// with rustdoc running in parallel.
all_indexes.sort();
write_crate("search-index.js", &|| {
let mut v = String::from("var searchIndex = JSON.parse('{\\\n");
v.push_str(&all_indexes.join(",\\\n"));
v.push_str("\\\n}');\ninitSearch(searchIndex);");
let v = static_files::SEARCH_JS
.replace(r#""SEARCH_INDEX_PLACEHOLDER": {}"#, &all_indexes.join(",\\\n"));
Ok(v.into_bytes())
})?;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,10 @@ crate static NORMALIZE_CSS: &str = include_str!("static/normalize.css");
/// including search behavior and docblock folding, among others.
crate static MAIN_JS: &str = include_str!("static/main.js");
/// The file contents of `search-index.js`, which contains the search behavior,
/// and into which is interpolated the search index.
crate static SEARCH_JS: &str = include_str!("static/search.js");
/// The file contents of `settings.js`, which contains the JavaScript used to handle the settings
/// page.
crate static SETTINGS_JS: &str = include_str!("static/settings.js");