@@ -28,7 +28,7 @@ export class OpenZeppelinDocsIngester extends AsciiDocIngester {
2828 const config : BookConfig = {
2929 repoOwner : 'OpenZeppelin' ,
3030 repoName : 'cairo-contracts' ,
31- fileExtension : '.adoc' ,
31+ fileExtensions : [ '.adoc' ] ,
3232 chunkSize : 4096 ,
3333 chunkOverlap : 512 ,
3434 baseUrl : 'https://docs.openzeppelin.com' ,
@@ -68,31 +68,33 @@ export class OpenZeppelinDocsIngester extends AsciiDocIngester {
6868 const entries = await fsPromises . readdir ( dir , { withFileTypes : true } ) ;
6969
7070 for ( const entry of entries ) {
71- const fullPath = path . join ( dir , entry . name ) ;
71+ for ( const fileExtension of config . fileExtensions ) {
72+ const fullPath = path . join ( dir , entry . name ) ;
7273
73- if ( entry . isDirectory ( ) ) {
74- // Recursively process subdirectories
75- await processDirectory ( fullPath ) ;
76- } else if (
77- entry . isFile ( ) &&
78- path . extname ( entry . name ) . toLowerCase ( ) === config . fileExtension
79- ) {
80- // Process AsciiDoc files
81- const content = await fsPromises . readFile ( fullPath , 'utf8' ) ;
74+ if ( entry . isDirectory ( ) ) {
75+ // Recursively process subdirectories
76+ await processDirectory ( fullPath ) ;
77+ } else if (
78+ entry . isFile ( ) &&
79+ path . extname ( entry . name ) . toLowerCase ( ) === fileExtension // TODO: handle multiple extensions
80+ ) {
81+ // Process AsciiDoc files
82+ const content = await fsPromises . readFile ( fullPath , 'utf8' ) ;
8283
83- // Get the relative path of the file from the base directory - which reflects the online website directory structure
84- const relativePath = path . relative ( directory , fullPath ) ;
84+ // Get the relative path of the file from the base directory - which reflects the online website directory structure
85+ const relativePath = path . relative ( directory , fullPath ) ;
8586
86- // Inject cairo-contracts/2.0.0 in the fullPath to reflect online website directory structure
87- // This is the special handling for OpenZeppelin docs
88- const adaptedFullPageName = path
89- . join ( 'contracts-cairo' , OZ_DOCS_VERSION , relativePath )
90- . replace ( config . fileExtension , '' ) ;
87+ // Inject cairo-contracts/2.0.0 in the fullPath to reflect online website directory structure
88+ // This is the special handling for OpenZeppelin docs
89+ const adaptedFullPageName = path
90+ . join ( 'contracts-cairo' , OZ_DOCS_VERSION , relativePath )
91+ . replace ( fileExtension , '' ) ;
9192
92- pages . push ( {
93- name : adaptedFullPageName ,
94- content,
95- } ) ;
93+ pages . push ( {
94+ name : adaptedFullPageName ,
95+ content,
96+ } ) ;
97+ }
9698 }
9799 }
98100 }
0 commit comments