move templating from searchtools to documentation_options

This commit is contained in:
Timotheus Kampik 2018-07-22 11:01:28 +02:00
parent d2a15f4035
commit 67cb316ba2
2 changed files with 50 additions and 44 deletions

View File

@ -6,5 +6,19 @@ var DOCUMENTATION_OPTIONS = {
FILE_SUFFIX: '{{ '' if no_search_suffix else file_suffix }}', FILE_SUFFIX: '{{ '' if no_search_suffix else file_suffix }}',
HAS_SOURCE: {{ has_source|lower }}, HAS_SOURCE: {{ has_source|lower }},
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}', SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}',
NAVIGATION_WITH_KEYS: {{ 'true' if theme_navigation_with_keys|tobool else 'false'}} NAVIGATION_WITH_KEYS: {{ 'true' if theme_navigation_with_keys|tobool else 'false'}},
SEARCH_LANGUAGE_STOP_WORDS: {{ search_language_stop_words }}
}; };
{% if search_language_stemming_code %}
/* Non-minified version JS is _stemmer.js if file is provided */ {% endif -%}
{{ search_language_stemming_code|safe }}
{% if search_scorer_tool %}
{{ search_scorer_tool|safe }}
{% endif -%}
{% if search_word_splitter_code %}
{{ search_word_splitter_code }}
{% endif -%}

View File

@ -9,17 +9,11 @@
* *
*/ */
{% if search_language_stemming_code %} if (!Scorer) {
/* Non-minified version JS is _stemmer.js if file is provided */ {% endif -%} /**
{{ search_language_stemming_code|safe }}
{% if search_scorer_tool %}
{{ search_scorer_tool|safe }}
{% else %}
/**
* Simple result scoring code. * Simple result scoring code.
*/ */
var Scorer = { var Scorer = {
// Implement the following function to further tweak the score for each result // Implement the following function to further tweak the score for each result
// The function takes a result array [filename, title, anchor, descr, score] // The function takes a result array [filename, title, anchor, descr, score]
// and returns the new score. // and returns the new score.
@ -44,16 +38,14 @@ var Scorer = {
title: 15, title: 15,
// query found in terms // query found in terms
term: 5 term: 5
}; };
{% endif %} }
{% if search_word_splitter_code %} if (!splitQuery) {
{{ search_word_splitter_code }} function splitQuery(query) {
{% else %} return query.split(/\s+/);
function splitQuery(query) { }
return query.split(/\s+/);
} }
{% endif %}
/** /**
* Search Module * Search Module
@ -146,7 +138,7 @@ var Search = {
*/ */
query : function(query) { query : function(query) {
var i; var i;
var stopwords = {{ search_language_stop_words }}; var stopwords = DOCUMENTATION_OPTIONS.SEARCH_LANGUAGE_STOP_WORDS;
// stem the searchterms and add them to the correct list // stem the searchterms and add them to the correct list
var stemmer = new Stemmer(); var stemmer = new Stemmer();