update docs [bot]
This commit is contained in:
		
							
								
								
									
										26
									
								
								docs/_static/searchtools.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								docs/_static/searchtools.js
									
									
									
									
										vendored
									
									
								
							| @@ -57,12 +57,12 @@ const _removeChildren = (element) => { | ||||
| const _escapeRegExp = (string) => | ||||
|   string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string | ||||
|  | ||||
| const _displayItem = (item, searchTerms) => { | ||||
| const _displayItem = (item, searchTerms, highlightTerms) => { | ||||
|   const docBuilder = DOCUMENTATION_OPTIONS.BUILDER; | ||||
|   const docUrlRoot = DOCUMENTATION_OPTIONS.URL_ROOT; | ||||
|   const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX; | ||||
|   const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX; | ||||
|   const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY; | ||||
|   const contentRoot = document.documentElement.dataset.content_root; | ||||
|  | ||||
|   const [docName, title, anchor, descr, score, _filename] = item; | ||||
|  | ||||
| @@ -75,20 +75,24 @@ const _displayItem = (item, searchTerms) => { | ||||
|     if (dirname.match(/\/index\/$/)) | ||||
|       dirname = dirname.substring(0, dirname.length - 6); | ||||
|     else if (dirname === "index/") dirname = ""; | ||||
|     requestUrl = docUrlRoot + dirname; | ||||
|     requestUrl = contentRoot + dirname; | ||||
|     linkUrl = requestUrl; | ||||
|   } else { | ||||
|     // normal html builders | ||||
|     requestUrl = docUrlRoot + docName + docFileSuffix; | ||||
|     requestUrl = contentRoot + docName + docFileSuffix; | ||||
|     linkUrl = docName + docLinkSuffix; | ||||
|   } | ||||
|   let linkEl = listItem.appendChild(document.createElement("a")); | ||||
|   linkEl.href = linkUrl + anchor; | ||||
|   linkEl.dataset.score = score; | ||||
|   linkEl.innerHTML = title; | ||||
|   if (descr) | ||||
|   if (descr) { | ||||
|     listItem.appendChild(document.createElement("span")).innerHTML = | ||||
|       " (" + descr + ")"; | ||||
|     // highlight search terms in the description | ||||
|     if (SPHINX_HIGHLIGHT_ENABLED)  // set in sphinx_highlight.js | ||||
|       highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted")); | ||||
|   } | ||||
|   else if (showSearchSummary) | ||||
|     fetch(requestUrl) | ||||
|       .then((responseData) => responseData.text()) | ||||
| @@ -97,6 +101,9 @@ const _displayItem = (item, searchTerms) => { | ||||
|           listItem.appendChild( | ||||
|             Search.makeSearchSummary(data, searchTerms) | ||||
|           ); | ||||
|         // highlight search terms in the summary | ||||
|         if (SPHINX_HIGHLIGHT_ENABLED)  // set in sphinx_highlight.js | ||||
|           highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted")); | ||||
|       }); | ||||
|   Search.output.appendChild(listItem); | ||||
| }; | ||||
| @@ -115,14 +122,15 @@ const _finishSearch = (resultCount) => { | ||||
| const _displayNextItem = ( | ||||
|   results, | ||||
|   resultCount, | ||||
|   searchTerms | ||||
|   searchTerms, | ||||
|   highlightTerms, | ||||
| ) => { | ||||
|   // results left, load the summary and display it | ||||
|   // this is intended to be dynamic (don't sub resultsCount) | ||||
|   if (results.length) { | ||||
|     _displayItem(results.pop(), searchTerms); | ||||
|     _displayItem(results.pop(), searchTerms, highlightTerms); | ||||
|     setTimeout( | ||||
|       () => _displayNextItem(results, resultCount, searchTerms), | ||||
|       () => _displayNextItem(results, resultCount, searchTerms, highlightTerms), | ||||
|       5 | ||||
|     ); | ||||
|   } | ||||
| @@ -360,7 +368,7 @@ const Search = { | ||||
|     // console.info("search results:", Search.lastresults); | ||||
|  | ||||
|     // print the results | ||||
|     _displayNextItem(results, results.length, searchTerms); | ||||
|     _displayNextItem(results, results.length, searchTerms, highlightTerms); | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user