@@ -284,54 +284,48 @@ function shouldIncludeFile(filename: string, ignore: string[] = []): boolean {
284
284
return true ;
285
285
}
286
286
287
- export function generateLlmContent (
288
- filteredDocs : Record < string , string > ,
289
- type : Package ,
290
- minimizeOptions ?: Partial < MinimizeOptions >
291
- ) : string {
292
- let content = `<SYSTEM>${ getDocumentationTitle ( type ) } </SYSTEM>\n\n` ;
293
-
294
- const paths = sortPaths ( Object . keys ( filteredDocs ) ) ;
295
-
296
- for ( const path of paths ) {
297
- content += `# ${ path . replace ( '../../../content/' , '' ) } \n\n` ;
298
- const docContent = minimizeOptions
299
- ? minimizeContent ( filteredDocs [ path ] , minimizeOptions )
300
- : filteredDocs [ path ] ;
301
- content += docContent ;
302
- content += '\n' ;
303
- }
304
-
305
- return content ;
287
+ interface GenerateContentOptions {
288
+ prefix ?: string ;
289
+ ignore ?: string [ ] ;
290
+ minimize ?: Partial < MinimizeOptions > ;
291
+ package ?: Package ;
306
292
}
307
293
308
- export function generateCombinedContent (
309
- documentsContent : Record < string , string > ,
310
- ignore : string [ ] = [ ] ,
311
- minimizeOptions ?: Partial < MinimizeOptions >
294
+ export function generateContent (
295
+ docs : Record < string , string > ,
296
+ options : GenerateContentOptions = { }
312
297
) : string {
298
+ const { prefix, ignore = [ ] , minimize : minimizeOptions , package : pkg } = options ;
299
+
313
300
let content = '' ;
301
+ if ( prefix ) {
302
+ content = `${ prefix } \n\n` ;
303
+ }
304
+
314
305
let currentSection = '' ;
315
- const paths = sortPaths ( Object . keys ( documentsContent ) ) ;
306
+ const paths = sortPaths ( Object . keys ( docs ) ) ;
316
307
317
308
for ( const path of paths ) {
318
- // Skip files that match ignore patterns
319
309
if ( ! shouldIncludeFile ( path , ignore ) ) continue ;
320
310
321
- const docType = packages . find ( ( pkg ) => path . includes ( `/docs/${ pkg } /` ) ) ;
322
- if ( ! docType ) continue ;
323
-
324
- const section = getDocumentationStartTitle ( docType ) ;
325
- if ( section !== currentSection ) {
326
- if ( currentSection ) content += '\n' ;
327
- content += `${ section } \n\n` ;
328
- currentSection = section ;
311
+ // If a specific package is provided, only include its docs
312
+ if ( pkg ) {
313
+ if ( ! path . includes ( `/docs/${ pkg } /` ) ) continue ;
314
+ } else {
315
+ // For combined content, only include paths that match any package
316
+ const docType = packages . find ( ( p ) => path . includes ( `/docs/${ p } /` ) ) ;
317
+ if ( ! docType ) continue ;
318
+
319
+ const section = getDocumentationStartTitle ( docType ) ;
320
+ if ( section !== currentSection ) {
321
+ if ( currentSection ) content += '\n' ;
322
+ content += `${ section } \n\n` ;
323
+ currentSection = section ;
324
+ }
329
325
}
330
326
331
327
content += `## ${ path . replace ( '../../../content/' , '' ) } \n\n` ;
332
- const docContent = minimizeOptions
333
- ? minimizeContent ( documentsContent [ path ] , minimizeOptions )
334
- : documentsContent [ path ] ;
328
+ const docContent = minimizeOptions ? minimizeContent ( docs [ path ] , minimizeOptions ) : docs [ path ] ;
335
329
content += docContent ;
336
330
content += '\n' ;
337
331
}
0 commit comments