@@ -26,6 +26,32 @@ function toFolderName(name) {
2626 . replace ( / ^ _ + | _ + $ / g, '' )
2727}
2828
29+ function toSlug ( name ) {
30+ return String ( name )
31+ . toLowerCase ( )
32+ . replace ( / [ ^ a - z 0 - 9 ] + / g, '-' )
33+ . replace ( / ^ - + | - $ / g, '' )
34+ }
35+
36+ function parseREADME ( filePath ) {
37+ try {
38+ const content = fs . readFileSync ( filePath , 'utf8' )
39+
40+ // Extract name
41+ const nameMatch = content . match ( / \* \* N a m e : \* \* \s * ( .+ ) / )
42+ const name = nameMatch ? nameMatch [ 1 ] . trim ( ) : ''
43+
44+ // Extract description (everything between "Description:" and the next heading or end)
45+ const descMatch = content . match ( / \* \* D e s c r i p t i o n : \* \* \s * \n \n ( .+ ?) (?: \n \n < h 2 | < h 3 | \n < p a l i g n | $ ) / s)
46+ const description = descMatch ? descMatch [ 1 ] . trim ( ) : ''
47+
48+ return { name, description }
49+ } catch ( error ) {
50+ return { name : '' , description : '' }
51+ }
52+ }
53+
54+ // First, copy README.md files as about.md
2955for ( const mod of modules ) {
3056 const id = mod . versionID || ''
3157 if ( ! id ) continue
@@ -42,3 +68,48 @@ for (const mod of modules) {
4268}
4369
4470console . log ( 'README.md files copied as about.md.' )
71+
72+ // Generate modules.md
73+ const outputPath = path . join ( __dirname , 'documentation' , 'modules.md' )
74+ const outputDir = path . dirname ( outputPath )
75+
76+ // Ensure documentation directory exists
77+ fs . mkdirSync ( outputDir , { recursive : true } )
78+
79+ let moduleList = [ ]
80+
81+ // Get all directories in the current folder
82+ const entries = fs . readdirSync ( __dirname , { withFileTypes : true } )
83+
84+ for ( const entry of entries ) {
85+ if ( ! entry . isDirectory ( ) ) continue
86+ if ( entry . name === '.github' || entry . name === 'node_modules' || entry . name === 'documentation' ) continue
87+
88+ const moduleDir = path . join ( __dirname , entry . name )
89+ const readmePath = path . join ( moduleDir , 'README.md' )
90+
91+ if ( ! fs . existsSync ( readmePath ) ) continue
92+
93+ const { name, description } = parseREADME ( readmePath )
94+ if ( ! name ) continue
95+
96+ moduleList . push ( { name, description, folder : entry . name } )
97+ }
98+
99+ // Sort modules alphabetically
100+ moduleList . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
101+
102+ // Generate markdown content
103+ let markdown = '# List of Modules\n\n'
104+
105+ for ( const module of moduleList ) {
106+ const slug = toSlug ( module . name )
107+ const url = `https://bleonheart.github.io/modules/${ slug } /`
108+
109+ markdown += `## [${ module . name } ](${ url } )\n`
110+ markdown += `${ module . description } \n\n`
111+ }
112+
113+ fs . writeFileSync ( outputPath , markdown )
114+
115+ console . log ( `Generated modules.md with ${ moduleList . length } modules at ${ outputPath } ` )
0 commit comments