MCPcopy Create free account
hub / github.com/electronstudio/raylib-python-cffi / objectSearchCallback

Function objectSearchCallback

docs/_static/searchtools.js:491–542  ·  view source on GitHub ↗
(prefix, match)

Source from the content-addressed store, hash-verified

489 const results = [];
490
491 const objectSearchCallback = (prefix, match) => {
492 const name = match[4];
493 const fullname = (prefix ? prefix + "." : "") + name;
494 const fullnameLower = fullname.toLowerCase();
495 if (fullnameLower.indexOf(object) < 0) return;
496
497 let score = 0;
498 const parts = fullnameLower.split(".");
499
500 // check for different match types: exact matches of full name or
501 // "last name" (i.e. last dotted part)
502 if (fullnameLower === object || parts.slice(-1)[0] === object)
503 score += Scorer.objNameMatch;
504 else if (parts.slice(-1)[0].indexOf(object) > -1)
505 score += Scorer.objPartialMatch; // matches in last name
506
507 const objName = objNames[match[1]][2];
508 const title = titles[match[0]];
509
510 // If more than one term searched for, we require other words to be
511 // found in the name/title/description
512 const otherTerms = new Set(objectTerms);
513 otherTerms.delete(object);
514 if (otherTerms.size > 0) {
515 const haystack = `${prefix} ${name} ${objName} ${title}`.toLowerCase();
516 if (
517 [...otherTerms].some((otherTerm) => haystack.indexOf(otherTerm) < 0)
518 )
519 return;
520 }
521
522 let anchor = match[3];
523 if (anchor === "") anchor = fullname;
524 else if (anchor === "-") anchor = objNames[match[1]][1] + "-" + fullname;
525
526 const descr = objName + _(", in ") + title;
527
528 // add custom score for some objects according to scorer
529 if (Scorer.objPrio.hasOwnProperty(match[2]))
530 score += Scorer.objPrio[match[2]];
531 else score += Scorer.objPrioDefault;
532
533 results.push([
534 docNames[match[0]],
535 fullname,
536 "#" + anchor,
537 descr,
538 score,
539 filenames[match[0]],
540 SearchResultKind.object,
541 ]);
542 };
543 Object.keys(objects).forEach((prefix) =>
544 objects[prefix].forEach((array) => objectSearchCallback(prefix, array)),
545 );

Callers 1

searchtools.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected