From 02123d66506735105e5e80cbe5cebca0c940279e Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 7 Dec 2008 23:16:57 +0100 Subject: [PATCH] Fix JS search when html_copy_source is off. --- CHANGES | 2 ++ doc/config.rst | 6 ++++++ sphinx/builder.py | 1 + sphinx/static/searchtools.js | 8 +++++++- sphinx/templates/layout.html | 9 +++++---- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index e3dc5cc6d..12f0384c8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ Release 0.5.1 (in development) ============================== +* Fix the JavaScript search when html_copy_source is off. + * Fix a bug in autodoc when documenting classes with the option. ``autoclass_content = "both"`` set. diff --git a/doc/config.rst b/doc/config.rst index b24e0277c..e6af9aae9 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -393,6 +393,12 @@ that use Sphinx' HTMLWriter class. If true, the reST sources are included in the HTML build as :file:`_sources/{name}`. The default is ``True``. + .. warning:: + + If this config value is set to ``False``, the JavaScript search function + will only display the titles of matching documents, and no excerpt from + the matching contents. + .. confval:: html_use_opensearch If nonempty, an `OpenSearch ` description file will be diff --git a/sphinx/builder.py b/sphinx/builder.py index 159fe8038..1d16c8eff 100644 --- a/sphinx/builder.py +++ b/sphinx/builder.py @@ -440,6 +440,7 @@ class StandaloneHTMLBuilder(Builder): docstitle = self.config.html_title, shorttitle = self.config.html_short_title, show_sphinx = self.config.html_show_sphinx, + has_source = self.config.html_copy_source, file_suffix = self.out_suffix, script_files = self.script_files, sphinx_version = __version__, diff --git a/sphinx/static/searchtools.js b/sphinx/static/searchtools.js index eb7d62c38..f9d9b6c39 100644 --- a/sphinx/static/searchtools.js +++ b/sphinx/static/searchtools.js @@ -431,7 +431,7 @@ var Search = { listItem.slideDown(5, function() { displayNextItem(); }); - } else { + } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { $.get('_sources/' + item[0] + '.txt', function(data) { listItem.append($.makeSearchSummary(data, searchterms, hlterms)); Search.output.append(listItem); @@ -439,6 +439,12 @@ var Search = { displayNextItem(); }); }); + } else { + // no source available, just display title + Search.output.append(listItem); + listItem.slideDown(5, function() { + displayNextItem(); + }); } } // search finished, update title and status message diff --git a/sphinx/templates/layout.html b/sphinx/templates/layout.html index 3efb7a8db..d9c9045d3 100644 --- a/sphinx/templates/layout.html +++ b/sphinx/templates/layout.html @@ -105,10 +105,11 @@ {%- if builder != 'htmlhelp' %} {%- for scriptfile in script_files %}