mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add html_search_* options templates to conf.py
Fix encode error when building Add printing search language label when building
This commit is contained in:
parent
a01e56fde9
commit
6892b5f191
@ -823,7 +823,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
self.info('done')
|
||||
|
||||
def dump_search_index(self):
|
||||
self.info(bold('dumping search index... '), nonl=True)
|
||||
self.info(bold('dumping search index in %s ... ' % self.indexer.label()), nonl=True)
|
||||
self.indexer.prune(self.env.all_docs)
|
||||
searchindexfn = path.join(self.outdir, self.searchindex_filename)
|
||||
# first write to a temporary file, so that if dumping fails,
|
||||
|
@ -220,10 +220,26 @@ html_static_path = ['%(dot)sstatic']
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Language to be used for generating the HTML full-text search index.
|
||||
# Sphinx supports the following languages:
|
||||
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
|
||||
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
|
||||
#html_search_language = 'en'
|
||||
|
||||
# A dictionary with options for the search language support, empty by default.
|
||||
# Now only 'ja' uses this config value
|
||||
#html_search_options = {'type': 'default'}
|
||||
|
||||
# The name of a javascript file (relative to the configuration directory) that
|
||||
# implements a search results scorer. If empty, the default will be used.
|
||||
#html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = '%(project_fn)sdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
|
@ -16,7 +16,6 @@ from docutils.nodes import raw, comment, title, Text, NodeVisitor, SkipNode
|
||||
|
||||
from sphinx.util import jsdump, rpartition
|
||||
|
||||
|
||||
class SearchLanguage(object):
|
||||
"""
|
||||
This class is the base class for search natural language preprocessors. If
|
||||
@ -40,6 +39,7 @@ class SearchLanguage(object):
|
||||
type, before searching index. Default implementation does nothing.
|
||||
"""
|
||||
lang = None
|
||||
language_name = None
|
||||
stopwords = set()
|
||||
js_stemmer_code = """
|
||||
/**
|
||||
@ -94,11 +94,26 @@ var Stemmer = function() {
|
||||
word.isdigit())))
|
||||
|
||||
|
||||
from sphinx.search import en, ja
|
||||
from sphinx.search import (
|
||||
da, de, en, es, fi, fr, hu, it, ja, nl, no, pt, ro, ru, sv, tr)
|
||||
|
||||
languages = {
|
||||
'da': da.SearchDanish,
|
||||
'de': de.SearchGerman,
|
||||
'en': en.SearchEnglish,
|
||||
'es': es.SearchSpanish,
|
||||
'fi': fi.SearchFinnish,
|
||||
'fr': fr.SearchFrench,
|
||||
'hu': hu.SearchHungarian,
|
||||
'it': it.SearchItalian,
|
||||
'ja': ja.SearchJapanese,
|
||||
'nl': nl.SearchDutch,
|
||||
'no': no.SearchNorwegian,
|
||||
'pt': pt.SearchPortuguese,
|
||||
'ro': ro.SearchRomanian,
|
||||
'ru': ru.SearchRussian,
|
||||
'sv': sv.SearchSwedish,
|
||||
'tr': tr.SearchTurkish
|
||||
}
|
||||
|
||||
|
||||
@ -185,7 +200,7 @@ class IndexBuilder(object):
|
||||
# objtype index -> (domain, type, objname (localized))
|
||||
self._objnames = {}
|
||||
# add language-specific SearchLanguage instance
|
||||
self.lang = languages[lang](options)
|
||||
self.lang = languages.get(lang, en.SearchEnglish)(options)
|
||||
|
||||
if scoring:
|
||||
with open(scoring, 'rb') as fp:
|
||||
@ -286,6 +301,9 @@ class IndexBuilder(object):
|
||||
objects=objects, objtypes=objtypes, objnames=objnames,
|
||||
titleterms=title_terms, envversion=self.env.version)
|
||||
|
||||
def label(self):
|
||||
return "%s (code: %s)" % (self.lang.language_name, self.lang.lang)
|
||||
|
||||
def prune(self, filenames):
|
||||
"""Remove data for all filenames not in the list."""
|
||||
new_titles = {}
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -226,6 +226,7 @@ iti|ous|ive|ize)$/;
|
||||
|
||||
class SearchEnglish(SearchLanguage):
|
||||
lang = 'en'
|
||||
language_name = 'English'
|
||||
js_stemmer_code = js_porter_stemmer
|
||||
stopwords = english_stopwords
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -254,6 +254,7 @@ class SearchJapanese(SearchLanguage):
|
||||
complicated.
|
||||
"""
|
||||
lang = 'ja'
|
||||
language_name = 'Japanese'
|
||||
|
||||
def init(self, options):
|
||||
type = options.get('type', 'default')
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user