@@ -22,6 +22,7 @@ import type { IAstModuleExportInfo } from '../analyzer/AstModule';
22
22
import { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter' ;
23
23
import { ExtractorMessageId } from '../api/ExtractorMessageId' ;
24
24
import type { ApiReportVariant } from '../api/IConfigFile' ;
25
+ import type { SymbolMetadata } from '../collector/SymbolMetadata' ;
25
26
26
27
export class ApiReportGenerator {
27
28
private static _trimSpacesRegExp : RegExp = / + $ / gm;
@@ -93,6 +94,13 @@ export class ApiReportGenerator {
93
94
// Emit the regular declarations
94
95
for ( const entity of collector . entities ) {
95
96
const astEntity : AstEntity = entity . astEntity ;
97
+ const symbolMetadata : SymbolMetadata | undefined = collector . tryFetchMetadataForAstEntity ( astEntity ) ;
98
+ const maxEffectiveReleaseTag : ReleaseTag = symbolMetadata ?. maxEffectiveReleaseTag ?? ReleaseTag . None ;
99
+
100
+ if ( ! this . _shouldIncludeReleaseTag ( maxEffectiveReleaseTag , reportVariant ) ) {
101
+ continue ;
102
+ }
103
+
96
104
if ( entity . consumable || collector . extractorConfig . apiReportIncludeForgottenExports ) {
97
105
// First, collect the list of export names for this symbol. When reporting messages with
98
106
// ExtractorMessage.properties.exportName, this will enable us to emit the warning comments alongside
@@ -133,7 +141,7 @@ export class ApiReportGenerator {
133
141
messagesToReport . push ( message ) ;
134
142
}
135
143
136
- if ( this . _shouldIncludeInReport ( collector , astDeclaration , reportVariant ) ) {
144
+ if ( this . _shouldIncludeDeclaration ( collector , astDeclaration , reportVariant ) ) {
137
145
writer . ensureSkippedLine ( ) ;
138
146
writer . write ( ApiReportGenerator . _getAedocSynopsis ( collector , astDeclaration , messagesToReport ) ) ;
139
147
@@ -276,7 +284,7 @@ export class ApiReportGenerator {
276
284
) : void {
277
285
// Should we process this declaration at all?
278
286
// eslint-disable-next-line no-bitwise
279
- if ( ! ApiReportGenerator . _shouldIncludeInReport ( collector , astDeclaration , reportVariant ) ) {
287
+ if ( ! ApiReportGenerator . _shouldIncludeDeclaration ( collector , astDeclaration , reportVariant ) ) {
280
288
span . modification . skipAll ( ) ;
281
289
return ;
282
290
}
@@ -420,7 +428,7 @@ export class ApiReportGenerator {
420
428
astDeclaration
421
429
) ;
422
430
423
- if ( ApiReportGenerator . _shouldIncludeInReport ( collector , childAstDeclaration , reportVariant ) ) {
431
+ if ( ApiReportGenerator . _shouldIncludeDeclaration ( collector , childAstDeclaration , reportVariant ) ) {
424
432
if ( sortChildren ) {
425
433
span . modification . sortChildren = true ;
426
434
child . modification . sortKey = Collector . getSortKeyIgnoringUnderscore (
@@ -456,7 +464,7 @@ export class ApiReportGenerator {
456
464
}
457
465
}
458
466
459
- private static _shouldIncludeInReport (
467
+ private static _shouldIncludeDeclaration (
460
468
collector : Collector ,
461
469
astDeclaration : AstDeclaration ,
462
470
reportVariant : ApiReportVariant
@@ -469,22 +477,34 @@ export class ApiReportGenerator {
469
477
470
478
const apiItemMetadata : ApiItemMetadata = collector . fetchApiItemMetadata ( astDeclaration ) ;
471
479
472
- // No specified release tag is considered the same as `@public`.
473
- const releaseTag : ReleaseTag =
474
- apiItemMetadata . effectiveReleaseTag === ReleaseTag . None
475
- ? ReleaseTag . Public
476
- : apiItemMetadata . effectiveReleaseTag ;
480
+ return this . _shouldIncludeReleaseTag ( apiItemMetadata . effectiveReleaseTag , reportVariant ) ;
481
+ }
477
482
478
- // If the declaration has a release tag that is not in scope, omit it from the report.
483
+ private static _shouldIncludeReleaseTag ( releaseTag : ReleaseTag , reportVariant : ApiReportVariant ) : boolean {
479
484
switch ( reportVariant ) {
480
485
case 'complete' :
481
486
return true ;
482
487
case 'alpha' :
483
- return releaseTag >= ReleaseTag . Alpha ;
488
+ return (
489
+ releaseTag === ReleaseTag . Alpha ||
490
+ releaseTag === ReleaseTag . Beta ||
491
+ releaseTag === ReleaseTag . Public ||
492
+ // NOTE: No specified release tag is implicitly treated as `@public`.
493
+ releaseTag === ReleaseTag . None
494
+ ) ;
484
495
case 'beta' :
485
- return releaseTag >= ReleaseTag . Beta ;
496
+ return (
497
+ releaseTag === ReleaseTag . Beta ||
498
+ releaseTag === ReleaseTag . Public ||
499
+ // NOTE: No specified release tag is implicitly treated as `@public`.
500
+ releaseTag === ReleaseTag . None
501
+ ) ;
486
502
case 'public' :
487
- return releaseTag === ReleaseTag . Public ;
503
+ return (
504
+ releaseTag === ReleaseTag . Public ||
505
+ // NOTE: No specified release tag is implicitly treated as `@public`.
506
+ releaseTag === ReleaseTag . None
507
+ ) ;
488
508
default :
489
509
throw new Error ( `Unrecognized release level: ${ reportVariant } ` ) ;
490
510
}
0 commit comments