@@ -451,8 +451,35 @@ export class Converter extends AbstractComponent<Application, ConverterEvents> {
451
451
}
452
452
}
453
453
454
+ /**
455
+ * Permit deferred conversion steps to take place. Until this is called, {@link deferConversion}
456
+ * will throw if used.
457
+ * @since 0.28.1
458
+ */
459
+ permitDeferredConversion ( ) : void {
460
+ ok ( ! this . _deferPermitted , "Attempted to allow deferred conversion when already permitted" ) ;
461
+ this . _deferPermitted = true ;
462
+ }
463
+
464
+ /**
465
+ * Finalize deferred conversion, must be called by the caller of {@link permitDeferredConversion}
466
+ * @since 0.28.1
467
+ */
468
+ finalizeDeferredConversion ( ) : void {
469
+ this . application . logger . verbose ( `Have ${ this . _defer . length } initial deferred tasks` ) ;
470
+ let count = 0 ;
471
+ while ( this . _defer . length ) {
472
+ ++ count ;
473
+ const first = this . _defer . shift ( ) ! ;
474
+ first ( ) ;
475
+ }
476
+ this . application . logger . verbose ( `Ran ${ count } total deferred tasks` ) ;
477
+ this . _deferPermitted = false ;
478
+ }
479
+
454
480
/**
455
481
* Defer a conversion step until later. This may only be called during conversion.
482
+ * @since 0.28.0
456
483
*/
457
484
deferConversion ( cb : ( ) => void ) : void {
458
485
ok ( this . _deferPermitted , "Attempted to defer conversion when not permitted" ) ;
@@ -469,9 +496,7 @@ export class Converter extends AbstractComponent<Application, ConverterEvents> {
469
496
entryPoints : readonly DocumentationEntryPoint [ ] ,
470
497
context : Context ,
471
498
) {
472
- ok ( ! this . _deferPermitted ) ;
473
- this . _deferPermitted = true ;
474
-
499
+ this . permitDeferredConversion ( ) ;
475
500
let createModuleReflections = entryPoints . length > 1 ;
476
501
if ( ! createModuleReflections ) {
477
502
const opts = this . application . options ;
@@ -495,15 +520,7 @@ export class Converter extends AbstractComponent<Application, ConverterEvents> {
495
520
this . convertExports ( entryContext , entry , createModuleReflections ) ;
496
521
}
497
522
498
- this . application . logger . verbose ( `Have ${ this . _defer . length } initial deferred tasks` ) ;
499
- let count = 0 ;
500
- while ( this . _defer . length ) {
501
- ++ count ;
502
- const first = this . _defer . shift ( ) ! ;
503
- first ( ) ;
504
- }
505
- this . application . logger . verbose ( `Ran ${ count } total deferred tasks` ) ;
506
- this . _deferPermitted = false ;
523
+ this . finalizeDeferredConversion ( ) ;
507
524
}
508
525
509
526
private convertExports (
0 commit comments