comfit.Document
Incremental source document sharing compiled grammars with the calling thread.
Use create_document() to construct a session. A session snapshots the currently loaded languages. Dispose it explicitly or use it as a context manager.
Functions:
- dispose – Release retained trees. Existing snapshots remain valid. Repeated calls are harmless.
- highlight – Return an owned snapshot. Changes to source or rainbow options invalidate the cache.
- update – Incrementally parse changed source, releasing the GIL. If the source is unchanged, do nothing.
Attributes:
- source (
str) –
comfit.Document.dispose
dispose() -> None
Release retained trees. Existing snapshots remain valid. Repeated calls are harmless.
comfit.Document.highlight
highlight(config: HighlightConfig | None = None) -> HighlightResult
Return an owned snapshot. Changes to source or rainbow options invalidate the cache.
comfit.Document.source
source: str
comfit.Document.update
update(source: str) -> None
Incrementally parse changed source, releasing the GIL. If the source is unchanged, do nothing.