@@ -272,14 +272,9 @@ Other special nodes
272
272
Overriding the default search
273
273
-----------------------------
274
274
275
- Static sites usually have their own static index,
276
- and search results are retrieved via JavaScript.
277
- In order for Read the Docs to override the default search as expected,
278
- themes from the supported generators must follow these conventions.
279
-
280
- .. note ::
281
-
282
- Read the Docs will fallback to the original search in case of an error or no results.
275
+ Static sites usually have their own static search index, and search results are retrieved via JavaScript.
276
+ Read the Docs overrides the default search for Sphinx projects only,
277
+ and provides a fallback to the original search in case of an error or no results.
283
278
284
279
Sphinx
285
280
~~~~~~
@@ -317,70 +312,15 @@ If your theme works with the search from the basic theme, it will work with Read
317
312
318
313
.. _`static/searchtools.js` : https://github.com/sphinx-doc/sphinx/blob/275d9/sphinx/themes/basic/static/searchtools.js
319
314
320
- MkDocs
321
- ~~~~~~
322
-
323
- Search on MkDocs is provided by the `search plugin `_, which is included (and activated) by default in MkDocs.
324
- The js part of this plugin is included in the `templates/search/main.js `_ file,
325
- which subscribes to the ``keyup `` event of the ``#mkdocs-search-query `` element
326
- to call the ``doSearch `` function (available on MkDocs >= 1.x) on every key press.
327
-
328
- Read the Docs overrides the ``initSearch `` and ``doSearch `` functions
329
- to subscribe to the ``keyup `` event of the ``#mkdocs-search-query `` element,
330
- and puts the results into the ``#mkdocs-search-results `` element.
331
- A simplified example looks like this:
332
-
333
- .. code-block :: js
334
-
335
- var original_search = doSearch;
336
-
337
- function search_override () {
338
- var query = document .getElementById (' mkdocs-search-query' ).value ;
339
- var search_results = document .getElementById (' mkdocs-search-results' );
340
-
341
- var results = fetch_resuls (query);
342
- if (results) {
343
- empty_results (search_results)
344
- for (var i = 0 ; i < results .length ; i += 1 ) {
345
- var result = process_result (results[i]);
346
- append_result (result, search_results);
347
- }
348
- } else {
349
- original_search ();
350
- }
351
- }
352
-
353
- var init_override = function () {
354
- var search_input = document .getElementById (' mkdocs-search-query' );
355
- search_input .addEventListener (' keyup' , doSearch);
356
- };
357
-
358
- window .doSearch = search_override;
359
- window .initSearch = init_override;
360
-
361
- initSearch ();
362
-
363
- Highlights from results will be in a ``mark `` tag (``This is a <mark>result</mark> ``).
364
- If your theme works with the search plugin of MkDocs,
365
- and defines the ``#mkdocs-search-query `` and ``#mkdocs-search-results `` elements,
366
- it will work with Read the Docs' SSS.
367
-
368
- .. note ::
369
-
370
- Since the ``templates/search/main.js `` file is included after our custom search,
371
- it will subscribe to the ``keyup `` event too, triggering both functions when a key is pressed
372
- (but ours should have more precedence).
373
- This can be fixed by not including the ``search `` plugin (you won't be able to fallback to the original search),
374
- or by creating a custom plugin to include our search at the end (this should be done by Read the Docs).
315
+ Other static site generators
316
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
375
317
376
- .. _ `search plugin` : https://www.mkdocs.org/user-guide/configuration/#search
377
- .. _ `templates/ search/main.js` : https://github.com/mkdocs/mkdocs/blob/ff0b72/mkdocs/contrib/search/templates/search/main.js
318
+ All projects that have HTML pages that follow the conventions described in this document
319
+ can make use of the server side search from the dashboard or by calling the API.
378
320
379
321
Supporting more themes and static site generators
380
322
-------------------------------------------------
381
323
382
- Currently, Read the Docs supports building documentation from
383
- :doc: `Sphinx <rtd:intro/getting-started-with-sphinx >` and :doc: `MkDocs <rtd:intro/getting-started-with-mkdocs >`.
384
324
All themes that follow these conventions should work as expected.
385
325
If you think other generators or other conventions should be supported,
386
326
or content that should be ignored or have an especial treatment,
0 commit comments