@@ -19,6 +19,7 @@ const outputBase = path.join(process.cwd(), `patternfly-docs/generated`);
1919const tsDocs = { } ;
2020let functionDocs = { } ;
2121const routes = { } ;
22+ const pendingProps = [ ] ;
2223const globs = {
2324 props : [ ] ,
2425 md : [ ] ,
@@ -267,8 +268,8 @@ function toReactComponent(mdFilePath, source, buildMode) {
267268 } ;
268269}
269270
270- function sourcePropsFile ( file ) {
271- tsDocgen ( file )
271+ async function sourcePropsFile ( file ) {
272+ ( await tsDocgen ( file ) )
272273 . filter ( ( { hide } ) => ! hide )
273274 . forEach ( ( { name, description, props } ) => {
274275 tsDocs [ getTsDocName ( name , getTsDocNameVariant ( file ) ) ] = { name, description, props } ;
@@ -345,19 +346,32 @@ function getTsDocNameVariant(source) {
345346module . exports = {
346347 sourceProps ( glob , ignore ) {
347348 globs . props . push ( { glob, ignore } ) ;
348- globSync ( glob , { ignore } ) . forEach ( sourcePropsFile ) ;
349+ const promise = Promise . all ( globSync ( glob , { ignore } ) . map ( sourcePropsFile ) ) ;
350+ pendingProps . push ( promise ) ;
351+ } ,
352+ async waitForProps ( ) {
353+ await Promise . all ( pendingProps ) ;
349354 } ,
350355 sourceMD ( glob , source , ignore , buildMode ) {
351- globs . md . push ( { glob, source, ignore } ) ;
352- globSync ( glob , { ignore } ) . forEach ( file => sourceMDFile ( file , source , buildMode ) ) ;
356+ globs . md . push ( { glob, source, ignore, buildMode } ) ;
357+ } ,
358+ processMD ( ) {
359+ globs . md . forEach ( ( { glob, source, ignore, buildMode } ) => {
360+ globSync ( glob , { ignore } ) . forEach ( file => sourceMDFile ( file , source , buildMode ) ) ;
361+ } ) ;
353362 } ,
354363 sourceFunctionDocs,
355364 writeIndex,
356365 watchMD ( ) {
357366 globs . props . forEach ( ( { glob, ignore } ) => {
358367 const propWatcher = chokidar . watch ( globSync ( glob , { ignored : ignore , ignoreInitial : true } ) ) ;
359- propWatcher . on ( 'add' , sourcePropsFile ) ;
360- propWatcher . on ( 'change' , sourcePropsFile ) ;
368+ const onPropFile = ( file ) => {
369+ sourcePropsFile ( file ) . catch ( ( err ) => {
370+ console . error ( 'Error updating props from' , file , err ) ;
371+ } ) ;
372+ } ;
373+ propWatcher . on ( 'add' , onPropFile ) ;
374+ propWatcher . on ( 'change' , onPropFile ) ;
361375 } ) ;
362376 globs . md . forEach ( ( { glob, source, ignore } ) => {
363377 const mdWatcher = chokidar . watch ( globSync ( glob , { ignored : ignore , ignoreInitial : true } ) ) ;
0 commit comments