File tree 4 files changed +12
-9
lines changed
4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,8 @@ crate fn render<T: Print, S: Print>(
113
113
<section class=\" footer\" ></section>\
114
114
{after_content}\
115
115
<div id=\" rustdoc-vars\" data-root-path=\" {root_path}\" data-current-crate=\" {krate}\" \
116
- data-search-js=\" {root_path}search-index{suffix}.js\" ></div>
116
+ data-search-index-js=\" {root_path}search-index{suffix}.js\" \
117
+ data-search-js=\" {root_path}search{suffix}.js\" ></div>
117
118
<script src=\" {static_root_path}main{suffix}.js\" ></script>\
118
119
{extra_scripts}\
119
120
</body>\
Original file line number Diff line number Diff line change @@ -223,6 +223,7 @@ pub(super) fn write_shared(
223
223
& format ! ( " = {}" , serde_json:: to_string( & themes) . unwrap( ) ) ,
224
224
) ,
225
225
) ?;
226
+ write_minify ( "search.js" , static_files:: SEARCH_JS ) ?;
226
227
write_minify ( "settings.js" , static_files:: SETTINGS_JS ) ?;
227
228
if cx. shared . include_sources {
228
229
write_minify ( "source-script.js" , static_files:: sidebar:: SOURCE_SCRIPT ) ?;
@@ -408,8 +409,9 @@ pub(super) fn write_shared(
408
409
// with rustdoc running in parallel.
409
410
all_indexes. sort ( ) ;
410
411
write_crate ( "search-index.js" , & || {
411
- let v = static_files:: SEARCH_JS
412
- . replace ( r#""SEARCH_INDEX_PLACEHOLDER": {}"# , & all_indexes. join ( ",\\ \n " ) ) ;
412
+ let mut v = String :: from ( "var searchIndex = JSON.parse('{\\ \n " ) ;
413
+ v. push_str ( & all_indexes. join ( ",\\ \n " ) ) ;
414
+ v. push_str ( "\\ \n }');\n if (window.initSearch) {window.initSearch(searchIndex)};" ) ;
413
415
Ok ( v. into_bytes ( ) )
414
416
} ) ?;
415
417
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ if (!DOMTokenList.prototype.remove) {
43
43
window . rootPath = rustdocVars . attributes [ "data-root-path" ] . value ;
44
44
window . currentCrate = rustdocVars . attributes [ "data-current-crate" ] . value ;
45
45
window . searchJS = rustdocVars . attributes [ "data-search-js" ] . value ;
46
+ window . searchIndexJS = rustdocVars . attributes [ "data-search-index-js" ] . value ;
46
47
}
47
48
var sidebarVars = document . getElementById ( "sidebar-vars" ) ;
48
49
if ( sidebarVars ) {
@@ -247,6 +248,7 @@ function hideThemeButtonState() {
247
248
if ( ! searchLoaded ) {
248
249
searchLoaded = true ;
249
250
loadScript ( window . searchJS ) ;
251
+ loadScript ( window . searchIndexJS ) ;
250
252
}
251
253
}
252
254
Original file line number Diff line number Diff line change 1
1
( function ( ) {
2
- var searchIndex = JSON . parse ( '{\
3
- "SEARCH_INDEX_PLACEHOLDER": {}\
4
- }' ) ;
5
-
6
2
// This mapping table should match the discriminants of
7
3
// `rustdoc::html::item_type::ItemType` type in Rust.
8
4
var itemTypes = [ "mod" ,
@@ -104,7 +100,7 @@ function levenshtein(s1, s2) {
104
100
return s1_len + s2_len ;
105
101
}
106
102
107
- function initSearch ( rawSearchIndex ) {
103
+ window . initSearch = function ( rawSearchIndex ) {
108
104
var MAX_LEV_DISTANCE = 3 ;
109
105
var MAX_RESULTS = 200 ;
110
106
var GENERICS_DATA = 1 ;
@@ -1509,6 +1505,8 @@ function initSearch(rawSearchIndex) {
1509
1505
}
1510
1506
} ;
1511
1507
1508
+ if ( window . searchIndex !== undefined ) {
1509
+ initSearch ( window . searchIndex ) ;
1510
+ }
1512
1511
1513
- initSearch ( searchIndex ) ;
1514
1512
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments