FileExtractor.extract()method
Read a file and build a tree-element from its text content.
extract(file: BunFile): Promise<TreeElement>
new FileExtractor()
| Return | |
|---|---|
FileExtractor | Base extractor for a file in a tree. |
Base extractor for a file in a tree.
content.source to the file's absolute path (BunFile.name); throws RequiredError if missing or non-absolute.name to the basename without extension, preserving case (e.g. "OptionalSchema" from "OptionalSchema.ts"); URL paths use name.key to the verbatim filename including extension (e.g. "OptionalSchema.ts"). Keys are unique within a directoryMergingExtractor to pair siblings ({base}.md + {base}.ts) and by PackageExtractor to look up sources.title — title is only set by subclasses that have a confident source for one (e.g. MarkupExtractor uses the first <h1>). Renderers fall back to name when missing.MarkupExtractor, TypescriptExtractor) override extractProps() to parse the content into richer elements.new FileExtractor().extract(Bun.file("/abs/path/notes.txt"))Read a file and build a tree-element from its text content.
extract(file: BunFile): Promise<TreeElement>
Build the file element props from the extracted content.
extractProps(name: string, content: string): Partial<TreeElementProps> & { name: string }