1
1
import fs from "fs/promises" ;
2
- const basePath = new URL (
3
- "../../inputfiles/mdn/files/en-us/web/api/" ,
4
- import . meta. url ,
5
- ) ;
2
+ const basePath = new URL ( "../../inputfiles/mdn/files/en-us/" , import . meta. url ) ;
3
+ const inputPaths = [ "web/api/" , "webassembly/reference/javascript_interface/" ] ;
6
4
7
5
function extractSummary ( markdown : string ) : string {
8
6
// Remove frontmatter (--- at the beginning)
@@ -75,6 +73,10 @@ const paths: Record<string, string[]> = {
75
73
"web-api-interface" : [ ] ,
76
74
"webgl-extension" : [ ] ,
77
75
"webgl-extension-method" : [ "methods" , "method" ] ,
76
+ "webassembly-interface" : [ ] ,
77
+ "webassembly-instance-method" : [ "methods" , "method" ] ,
78
+ "webassembly-instance-property" : [ "properties" , "property" ] ,
79
+ "webassembly-static-method" : [ "methods" , "method" ] ,
78
80
} ;
79
81
80
82
function generatePath ( content : string ) : string [ ] | undefined {
@@ -87,8 +89,11 @@ function extractSlug(content: string): string[] {
87
89
const match = content . match ( / \n s l u g : ( .+ ) \n / ) ! ;
88
90
const url = match [ 1 ] . split ( ":" ) . pop ( ) ! ;
89
91
const normalized = url . endsWith ( "_static" ) ? url . slice ( 0 , - 7 ) : url ;
90
- const parts = normalized . split ( "/" ) . slice ( 2 ) ; // skip `Web/API/...`
91
- return parts ; // Keep only top-level and member name
92
+ const parts = normalized . split ( "/" ) ;
93
+ if ( parts [ 0 ] . toLowerCase ( ) === "web" ) {
94
+ return parts . slice ( 2 ) ;
95
+ }
96
+ return parts . slice ( 3 ) ;
92
97
}
93
98
94
99
function ensureLeaf ( obj : Record < string , any > , keys : string [ ] ) {
@@ -127,7 +132,11 @@ export async function generateDescriptions(): Promise<{
127
132
}
128
133
129
134
const results : Record < string , any > = { } ;
130
- const indexPaths = await walkDirectory ( basePath ) ;
135
+ const indexPaths = await Promise . all (
136
+ inputPaths . map (
137
+ async ( path ) => await walkDirectory ( new URL ( path , basePath ) ) ,
138
+ ) ,
139
+ ) . then ( ( res ) => res . flat ( ) ) ;
131
140
132
141
await Promise . all (
133
142
indexPaths . map ( async ( fileURL ) => {
0 commit comments