Skip to content

Commit 2be0630

Browse files
authored
Merge pull request #10108 from tk0miya/9456_html_show_search_summary
Close #9456: html search: Add a config variable; html_show_search_summary
2 parents d44ea70 + 72bb5c9 commit 2be0630

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Deprecated
1313
Features added
1414
--------------
1515

16+
* #9494, #9456: html search: Add a config variable
17+
:confval:`html_show_search_summary` to enable/disable the search summaries
18+
1619
Bugs fixed
1720
----------
1821

doc/usage/configuration.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,13 @@ that use Sphinx's HTMLWriter class.
13511351

13521352
.. versionadded:: 1.0
13531353

1354+
.. confval:: html_show_search_summary
1355+
1356+
If true, the text around the keyword is shown as summary of each search result.
1357+
Default is ``True``.
1358+
1359+
.. versionadded:: 4.5
1360+
13541361
.. confval:: html_show_sphinx
13551362

13561363
If true, "Created using Sphinx" is shown in the HTML footer. Default is

sphinx/builders/html/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ def prepare_writing(self, docnames: Set[str]) -> None:
509509
'docstitle': self.config.html_title,
510510
'shorttitle': self.config.html_short_title,
511511
'show_copyright': self.config.html_show_copyright,
512+
'show_search_summary': self.config.html_show_search_summary,
512513
'show_sphinx': self.config.html_show_sphinx,
513514
'has_source': self.config.html_copy_source,
514515
'show_source': self.config.html_show_sourcelink,
@@ -1340,6 +1341,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
13401341
app.add_config_value('html_file_suffix', None, 'html', [str])
13411342
app.add_config_value('html_link_suffix', None, 'html', [str])
13421343
app.add_config_value('html_show_copyright', True, 'html')
1344+
app.add_config_value('html_show_search_summary', True, 'html')
13431345
app.add_config_value('html_show_sphinx', True, 'html')
13441346
app.add_config_value('html_context', {}, 'html')
13451347
app.add_config_value('html_output_encoding', 'utf-8', 'html')

sphinx/themes/basic/static/documentation_options.js_t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ var DOCUMENTATION_OPTIONS = {
88
LINK_SUFFIX: '{{ link_suffix }}',
99
HAS_SOURCE: {{ has_source|lower }},
1010
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}',
11-
NAVIGATION_WITH_KEYS: {{ 'true' if theme_navigation_with_keys|tobool else 'false'}}
11+
NAVIGATION_WITH_KEYS: {{ 'true' if theme_navigation_with_keys|tobool else 'false'}},
12+
SHOW_SEARCH_SUMMARY: {{ 'true' if show_search_summary else 'false' }}
1213
};

sphinx/themes/basic/static/searchtools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ var Search = {
276276
setTimeout(function() {
277277
displayNextItem();
278278
}, 5);
279-
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
279+
} else if (DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY) {
280280
$.ajax({url: requestUrl,
281281
dataType: "text",
282282
complete: function(jqxhr, textstatus) {
@@ -293,7 +293,7 @@ var Search = {
293293
}, 5);
294294
}});
295295
} else {
296-
// no source available, just display title
296+
// just display title
297297
Search.output.append(listItem);
298298
setTimeout(function() {
299299
displayNextItem();

0 commit comments

Comments
 (0)