(docsPath: string)
| 37 | } |
| 38 | |
| 39 | async chunkAllDocs(docsPath: string): Promise<DocChunk[]> { |
| 40 | const allChunks: DocChunk[] = [] |
| 41 | |
| 42 | try { |
| 43 | const mdxFiles = await this.findMdxFiles(docsPath) |
| 44 | logger.info(`Found ${mdxFiles.length} .mdx files to process`) |
| 45 | |
| 46 | for (const filePath of mdxFiles) { |
| 47 | try { |
| 48 | const chunks = await this.chunkMdxFile(filePath, docsPath) |
| 49 | allChunks.push(...chunks) |
| 50 | logger.info(`Processed ${filePath}: ${chunks.length} chunks`) |
| 51 | } catch (error) { |
| 52 | logger.error(`Error processing ${filePath}:`, error) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | logger.info(`Total chunks generated: ${allChunks.length}`) |
| 57 | return allChunks |
| 58 | } catch (error) { |
| 59 | logger.error('Error processing docs:', error) |
| 60 | throw error |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | async chunkMdxFile(filePath: string, basePath: string): Promise<DocChunk[]> { |
| 65 | const content = await fs.readFile(filePath, 'utf-8') |
no test coverage detected