@@ -67,7 +67,27 @@ type ParsedProps = {
6767
6868/**
6969 * Note: For this code to run, you need to prefix the type with 'Public' (e.g., 'PublicMyType') in your TypeScript files
70- * and save the file. This convention helps the parser identify and process the public types correctly.
70+ *
71+ * * e.g:
72+ *
73+ * ```tsx
74+ * type PublicModalRootProps = {
75+ * //blablabla
76+ * onShow$?: QRL<() => void>;
77+ * //blablabla
78+ * onClose$?: QRL<() => void>;
79+ * //blablabla
80+ * 'bind:show'?: Signal<boolean>;
81+ * //blablabla
82+ * closeOnBackdropClick?: boolean;
83+ * //blablabla
84+ * alert?: boolean;
85+ * };
86+ * ```
87+ * This convention helps the parser identify and process the public types correctly.
88+ *
89+ * Now when you save the corresponding .mdx file, the API will be updated accordingly.
90+ *
7191 **/
7292
7393function parseSingleComponentFromDir (
@@ -104,9 +124,9 @@ function parseSingleComponentFromDir(
104124 }
105125 if ( capture . name === 'type' ) {
106126 parsedProps . type = capture . node . text ;
107- const lastKey = last ? Object . keys ( last ) [ 0 ] : '' ;
108- if ( subComponentName === lastKey ) {
109- last ! [ lastKey ] . push ( parsedProps ) ;
127+ const topKey = last ? Object . keys ( last ) [ 0 ] : '' ;
128+ if ( subComponentName === topKey ) {
129+ last [ topKey ] . push ( parsedProps ) ;
110130 } else {
111131 parsed . push ( { [ subComponentName ] : [ parsedProps ] } ) ;
112132 }
@@ -126,7 +146,7 @@ function writeToDocs(fullPath: string, componentName: string, api: ComponentPart
126146 const dirPath = resolve ( fullDocPath , 'auto-api' ) ;
127147
128148 if ( ! fs . existsSync ( dirPath ) ) {
129- fs . mkdirSync ( dirPath , { recursive : true } ) ;
149+ fs . mkdirSync ( dirPath ) ;
130150 }
131151 const json = JSON . stringify ( api , null , 2 ) ;
132152 const exportedApi = `export const api = ${ json } ;` ;
@@ -145,7 +165,7 @@ function loopOnAllChildFiles(filePath: string) {
145165 if ( ! childComponentMatch ) {
146166 return ;
147167 }
148- const parentDir = filePath . slice ( 0 , filePath . lastIndexOf ( childComponentMatch [ 0 ] ) ) ;
168+ const parentDir = filePath . replace ( childComponentMatch [ 0 ] , '' ) ;
149169 const componentMatch = / [ \\ / ] ( \w + ) $ / . exec ( parentDir ) ;
150170 if ( ! fs . existsSync ( parentDir ) || ! componentMatch ) {
151171 return ;
0 commit comments