Skip to content

Commit 62c2102

Browse files
committed
API Extractor now reports warnings when the underscore prefix is missing for an @internal definition, or redundantly applied to a non-@internal definition
1 parent 930b3cc commit 62c2102

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

‎libraries/api-extractor/src/definitions/ApiDocumentation.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,13 @@ export default class ApiDocumentation {
404404

405405
// If the apiDefinitionRef can not be found the resolvedApiItem will be
406406
// undefined and an error will have been reported via this.reportError
407-
if (resolvedApiItem && resolvedApiItem.releaseTag === ReleaseTag.Internal
408-
|| resolvedApiItem.releaseTag === ReleaseTag.Alpha) {
409-
this.reportError('The {@link} tag references an @internal or @alpha API item, '
410-
+ 'which will not appear in the generated documentation');
407+
if (resolvedApiItem) {
408+
if (resolvedApiItem.releaseTag === ReleaseTag.Internal
409+
|| resolvedApiItem.releaseTag === ReleaseTag.Alpha) {
410+
411+
this.reportError('The {@link} tag references an @internal or @alpha API item, '
412+
+ 'which will not appear in the generated documentation');
413+
}
411414
}
412415
}
413416
}

‎libraries/api-extractor/src/definitions/ApiItem.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,19 @@ abstract class ApiItem {
394394
this.reportError('The @inheritdoc target has been marked as @deprecated. ' +
395395
'Add a @deprecated message here, or else remove the @inheritdoc relationship.');
396396
}
397+
398+
if (this.name.substr(0, 1) === '_') {
399+
if (this.documentation.releaseTag !== ReleaseTag.Internal
400+
&& this.documentation.releaseTag !== ReleaseTag.None) {
401+
this.reportWarning('The underscore prefix ("_") should only be used with definitions'
402+
+ ' that are explicitly marked as @internal');
403+
}
404+
} else {
405+
if (this.documentation.releaseTag === ReleaseTag.Internal) {
406+
this.reportWarning('Because this definition is marked as @internal, an underscore prefix ("_") should'
407+
+ ' be added to its name');
408+
}
409+
}
397410
}
398411

399412
/**

0 commit comments

Comments
 (0)