Reference¶
Configuration¶
Set these in conf.py.
Option |
Default |
Description |
|---|---|---|
|
|
Name of the index file written to |
|
|
Maximum characters of body text kept per record. |
|
|
Ship the bundled dialog and its CSS. When |
|
|
Make the theme’s search box open the dialog. Has no effect when |
Index format¶
The index is a JSON array of records. Each page produces one record for the page and one for each section that has an anchor.
Key |
Description |
|---|---|
|
URL relative to the documentation root, with |
|
Title of the page. |
|
Section heading. Absent on page records. |
|
Text, truncated to |
engine.load() rewrites u to an absolute URL.
JavaScript API¶
The engine defines a global SearchLite object.
SearchLite.create({ url })¶
Returns an engine for the index at url. Nothing is fetched until load() is
called.
engine.load()¶
Fetches and indexes the records. Returns a promise. Repeated calls return the same promise. A failed fetch produces an empty index.
engine.ready()¶
Returns true once the index is built.
engine.search(query)¶
Returns { items, terms }. items is an array of up to 20 records, best match
first. terms lists the index terms that matched, including prefix expansions.
Returns empty arrays if the index is not loaded or the query has no words.
SearchLite.indexUrl¶
Absolute URL of the index for the current page, or null if it cannot be
resolved.
SearchLite.tokenize(text)¶
Returns the lowercase words in text, split on anything other than a-z,
0-9, and _.
SearchLite.excerpt(record, terms, length = 120)¶
Returns about length characters of record.x, starting just before the first
matching term. Prefixed with … when it does not start at the beginning.
SearchLite.highlight(text, terms)¶
Returns a DocumentFragment of text with each match wrapped in <mark>.
Dialog¶
Key |
Action |
|---|---|
|
Open the dialog. |
|
Move between results. |
|
Go to the selected result. |
|
Close the dialog. |
Any element with the data-searchlite-open attribute opens the dialog when
clicked.
CSS custom properties¶
Property |
Default |
Set on |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
foreground at 60% |
|
|
foreground at 20% |
|
|
foreground at 10% |
|