API Reference¶
This section provides detailed API documentation for all sphinx-typesense modules, classes, and functions.
Module Overview¶
sphinx-typesense consists of the following modules:
Module |
Description |
|---|---|
Configuration handling, validation, and defaults |
|
Content extraction and Typesense indexing |
|
HTML and JavaScript injection for search UI |
|
Theme-specific selectors and configuration |
Extension Entry Point¶
The main entry point is the setup function in the package root:
- sphinx_typesense.setup(app)[source]¶
Sphinx extension entry point.
Registers configuration values, connects to Sphinx build events, and adds static assets for the search UI.
- Parameters:
app (Sphinx) – The Sphinx application instance.
- Returns:
version: The extension version string
parallel_read_safe: Whether parallel reading is supported
parallel_write_safe: Whether parallel writing is supported
- Return type:
Extension metadata dictionary containing
Example
This function is called automatically by Sphinx when the extension is loaded. Users enable it by adding to conf.py:
extensions = ["sphinx_typesense"]
- sphinx_typesense.index_documents(app, exception)[source]¶
Sphinx event handler to index documents after build completes.
This function is connected to Sphinx’s
build-finishedevent and triggers the indexing of all HTML documents using the selected backend.- Parameters:
app (Sphinx) – The Sphinx application instance.
exception (Exception | None) – Exception raised during build, if any. When not None, indexing is skipped to avoid indexing partial or broken content.
Note
Indexing is controlled by the
typesense_enable_indexingconfig option. Set to False to disable automatic indexing (useful for development builds or when indexing is handled separately).Example
This function is called automatically by Sphinx after the build completes. It can also be invoked manually for testing:
index_documents(app, None)