mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Clean up the mechanism for disabling Javascript search.
This commit is contained in:
parent
0d01ca1dcf
commit
e490c2e12d
@ -78,6 +78,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
searchindex_filename = 'searchindex.js'
|
||||
add_permalinks = True
|
||||
embedded = False # for things like HTML help or Qt help: suppresses sidebar
|
||||
search = True # for things like HTML help and Apple help: suppress search
|
||||
|
||||
# This is a class attribute because it is mutated by Sphinx.add_javascript.
|
||||
script_files = ['_static/jquery.js', '_static/underscore.js',
|
||||
@ -247,6 +248,8 @@ class StandaloneHTMLBuilder(Builder):
|
||||
|
||||
def prepare_writing(self, docnames):
|
||||
# create the search indexer
|
||||
self.indexer = None
|
||||
if self.search:
|
||||
from sphinx.search import IndexBuilder, languages
|
||||
lang = self.config.html_search_language or self.config.language
|
||||
if not lang or lang not in languages:
|
||||
@ -484,12 +487,12 @@ class StandaloneHTMLBuilder(Builder):
|
||||
self.handle_page(pagename, {}, template)
|
||||
|
||||
# the search page
|
||||
if self.name != 'htmlhelp':
|
||||
if self.search:
|
||||
self.info(' search', nonl=1)
|
||||
self.handle_page('search', {}, 'search.html')
|
||||
|
||||
# the opensearch xml file
|
||||
if self.config.html_use_opensearch and self.name != 'htmlhelp':
|
||||
if self.config.html_use_opensearch and self.search:
|
||||
self.info(' opensearch', nonl=1)
|
||||
fn = path.join(self.outdir, '_static', 'opensearch.xml')
|
||||
self.handle_page('opensearch', {}, 'opensearch.xml', outfilename=fn)
|
||||
@ -579,8 +582,10 @@ class StandaloneHTMLBuilder(Builder):
|
||||
copyfile(jsfile, path.join(self.outdir, '_static',
|
||||
'translations.js'))
|
||||
|
||||
# add context items for search function used in searchtools.js_t
|
||||
ctx = self.globalcontext.copy()
|
||||
|
||||
# add context items for search function used in searchtools.js_t
|
||||
if self.indexer is not None:
|
||||
ctx.update(self.indexer.context_for_searchtool())
|
||||
|
||||
# then, copy over theme-supplied static files
|
||||
@ -801,6 +806,7 @@ class StandaloneHTMLBuilder(Builder):
|
||||
copyfile(self.env.doc2path(pagename), source_name)
|
||||
|
||||
def handle_finish(self):
|
||||
if self.indexer:
|
||||
self.finish_tasks.add_task(self.dump_search_index)
|
||||
self.finish_tasks.add_task(self.dump_inventory)
|
||||
|
||||
|
@ -173,6 +173,9 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder):
|
||||
# don't add sidebar etc.
|
||||
embedded = True
|
||||
|
||||
# don't generate search index or include search page
|
||||
search = False
|
||||
|
||||
lcid = 0x409
|
||||
encoding = 'cp1252'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user