mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Updated docfx. Generated fresh docs. Added an icon.
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
(function () {
|
||||
importScripts('lunr.min.js');
|
||||
|
||||
var lunrIndex = lunr(function () {
|
||||
this.pipeline.remove(lunr.stopWordFilter);
|
||||
this.ref('href');
|
||||
this.field('title', { boost: 50 });
|
||||
this.field('keywords', { boost: 20 });
|
||||
});
|
||||
lunr.tokenizer.seperator = /[\s\-\.]+/;
|
||||
var lunrIndex;
|
||||
|
||||
var stopWords = null;
|
||||
var searchData = {};
|
||||
|
||||
lunr.tokenizer.separator = /[\s\-\.]+/;
|
||||
|
||||
var stopWordsRequest = new XMLHttpRequest();
|
||||
stopWordsRequest.open('GET', '../search-stopwords.json');
|
||||
@@ -15,14 +14,11 @@
|
||||
if (this.status != 200) {
|
||||
return;
|
||||
}
|
||||
var stopWords = JSON.parse(this.responseText);
|
||||
var docfxStopWordFilter = lunr.generateStopWordFilter(stopWords);
|
||||
lunr.Pipeline.registerFunction(docfxStopWordFilter, 'docfxStopWordFilter');
|
||||
lunrIndex.pipeline.add(docfxStopWordFilter);
|
||||
stopWords = JSON.parse(this.responseText);
|
||||
buildIndex();
|
||||
}
|
||||
stopWordsRequest.send();
|
||||
|
||||
var searchData = {};
|
||||
var searchDataRequest = new XMLHttpRequest();
|
||||
|
||||
searchDataRequest.open('GET', '../index.json');
|
||||
@@ -31,11 +27,9 @@
|
||||
return;
|
||||
}
|
||||
searchData = JSON.parse(this.responseText);
|
||||
for (var prop in searchData) {
|
||||
if (searchData.hasOwnProperty(prop)) {
|
||||
lunrIndex.add(searchData[prop]);
|
||||
}
|
||||
}
|
||||
|
||||
buildIndex();
|
||||
|
||||
postMessage({ e: 'index-ready' });
|
||||
}
|
||||
searchDataRequest.send();
|
||||
@@ -50,4 +44,37 @@
|
||||
});
|
||||
postMessage({ e: 'query-ready', q: q, d: results });
|
||||
}
|
||||
|
||||
function buildIndex() {
|
||||
if (stopWords !== null && !isEmpty(searchData)) {
|
||||
lunrIndex = lunr(function () {
|
||||
this.pipeline.remove(lunr.stopWordFilter);
|
||||
this.ref('href');
|
||||
this.field('title', { boost: 50 });
|
||||
this.field('keywords', { boost: 20 });
|
||||
|
||||
for (var prop in searchData) {
|
||||
if (searchData.hasOwnProperty(prop)) {
|
||||
this.add(searchData[prop]);
|
||||
}
|
||||
}
|
||||
|
||||
var docfxStopWordFilter = lunr.generateStopWordFilter(stopWords);
|
||||
lunr.Pipeline.registerFunction(docfxStopWordFilter, 'docfxStopWordFilter');
|
||||
this.pipeline.add(docfxStopWordFilter);
|
||||
this.searchPipeline.add(docfxStopWordFilter);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function isEmpty(obj) {
|
||||
if(!obj) return true;
|
||||
|
||||
for (var prop in obj) {
|
||||
if (obj.hasOwnProperty(prop))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user