Skip to content

Commit

Permalink
Merge pull request #10108 from tk0miya/9456_html_show_search_summary
Browse files Browse the repository at this point in the history
Close #9456: html search: Add a config variable; html_show_search_summary
  • Loading branch information
tk0miya committed Jan 17, 2022
2 parents d44ea70 + 72bb5c9 commit 2be0630
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Expand Up @@ -13,6 +13,9 @@ Deprecated
Features added
--------------

* #9494, #9456: html search: Add a config variable
:confval:`html_show_search_summary` to enable/disable the search summaries

Bugs fixed
----------

Expand Down
7 changes: 7 additions & 0 deletions doc/usage/configuration.rst
Expand Up @@ -1351,6 +1351,13 @@ that use Sphinx's HTMLWriter class.

.. versionadded:: 1.0

.. confval:: html_show_search_summary

If true, the text around the keyword is shown as summary of each search result.
Default is ``True``.

.. versionadded:: 4.5

.. confval:: html_show_sphinx

If true, "Created using Sphinx" is shown in the HTML footer. Default is
Expand Down
2 changes: 2 additions & 0 deletions sphinx/builders/html/__init__.py
Expand Up @@ -509,6 +509,7 @@ def prepare_writing(self, docnames: Set[str]) -> None:
'docstitle': self.config.html_title,
'shorttitle': self.config.html_short_title,
'show_copyright': self.config.html_show_copyright,
'show_search_summary': self.config.html_show_search_summary,
'show_sphinx': self.config.html_show_sphinx,
'has_source': self.config.html_copy_source,
'show_source': self.config.html_show_sourcelink,
Expand Down Expand Up @@ -1340,6 +1341,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('html_file_suffix', None, 'html', [str])
app.add_config_value('html_link_suffix', None, 'html', [str])
app.add_config_value('html_show_copyright', True, 'html')
app.add_config_value('html_show_search_summary', True, 'html')
app.add_config_value('html_show_sphinx', True, 'html')
app.add_config_value('html_context', {}, 'html')
app.add_config_value('html_output_encoding', 'utf-8', 'html')
Expand Down
3 changes: 2 additions & 1 deletion sphinx/themes/basic/static/documentation_options.js_t
Expand Up @@ -8,5 +8,6 @@ var DOCUMENTATION_OPTIONS = {
LINK_SUFFIX: '{{ link_suffix }}',
HAS_SOURCE: {{ has_source|lower }},
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'}},
SHOW_SEARCH_SUMMARY: {{ 'true' if show_search_summary else 'false' }}
};
4 changes: 2 additions & 2 deletions sphinx/themes/basic/static/searchtools.js
Expand Up @@ -276,7 +276,7 @@ var Search = {
setTimeout(function() {
displayNextItem();
}, 5);
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
} else if (DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY) {
$.ajax({url: requestUrl,
dataType: "text",
complete: function(jqxhr, textstatus) {
Expand All @@ -293,7 +293,7 @@ var Search = {
}, 5);
}});
} else {
// no source available, just display title
// just display title
Search.output.append(listItem);
setTimeout(function() {
displayNextItem();
Expand Down

0 comments on commit 2be0630

Please sign in to comment.