generated docs: smart ignore case

master
Andrew Kelley 2019-10-07 18:12:28 -04:00
parent 9df0d53981
commit 478e53911d
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
1 changed files with 16 additions and 11 deletions

View File

@ -595,6 +595,7 @@
}
function renderSearch() {
var matchedItems = [];
var ignoreCase = (curNavSearch.toLowerCase() === curNavSearch);
var terms = curNavSearch.split(/[ \r\n\t]+/);
decl_loop: for (var declIndex = 0; declIndex < zigAnalysis.decls.length; declIndex += 1) {
@ -602,21 +603,25 @@
if (canonPath == null) continue;
var decl = zigAnalysis.decls[declIndex];
var lastPkgName = canonPath.pkgNames[canonPath.pkgNames.length - 1];
var searchText = lastPkgName + "." + canonPath.declNames.join('.');
var astNode = zigAnalysis.astNodes[decl.src];
if (astNode.docs != null) {
searchText += "\n" + astNode.docs;
}
var file = zigAnalysis.files[astNode.file];
searchText += "\n" + file;
if (ignoreCase) {
searchText = searchText.toLowerCase();
}
for (var termIndex = 0; termIndex < terms.length; termIndex += 1) {
var term = terms[termIndex];
if (decl.name.indexOf(term) >= 0) {
if (searchText.indexOf(term) >= 0) {
continue;
} else {
continue decl_loop;
}
var astNode = zigAnalysis.astNodes[decl.src];
if (astNode.docs != null && astNode.docs.indexOf(term) >= 0) {
continue;
}
var file = zigAnalysis.files[astNode.file];
if (file.indexOf(term) >= 0) {
continue;
}
continue decl_loop;
}
matchedItems.push({