@@ -16,7 +16,8 @@ import {
1616 IApiEnumMember ,
1717 IApiClass ,
1818 IApiInterface ,
19- Markup
19+ Markup ,
20+ ApiItem
2021} from '@microsoft/api-extractor' ;
2122
2223import { DocItemSet , DocItem , DocItemKind , IDocItemSetResolveResult } from '../utils/DocItemSet' ;
@@ -300,14 +301,28 @@ export class YamlDocumenter {
300301 if ( apiStructure . implements ) {
301302 yamlItem . implements = [ apiStructure . implements ] ;
302303 }
304+
305+ if ( apiStructure . isSealed ) {
306+ let sealedMessage : string ;
307+ if ( docItem . kind === DocItemKind . Class ) {
308+ sealedMessage = 'This class is marked as `@sealed`. Subclasses should not extend it.' ;
309+ } else {
310+ sealedMessage = 'This interface is marked as `@sealed`. Other interfaces should not extend it.' ;
311+ }
312+ if ( ! yamlItem . remarks ) {
313+ yamlItem . remarks = sealedMessage ;
314+ } else {
315+ yamlItem . remarks += sealedMessage + '\n\n' + yamlItem . remarks ;
316+ }
317+ }
303318 }
304319
305320 private _populateYamlMethod ( yamlItem : Partial < IYamlItem > , docItem : DocItem ) : void {
306321 const apiMethod : IApiMethod | IApiConstructor = docItem . apiItem as IApiMethod ;
307322 yamlItem . name = Utilities . getConciseSignature ( docItem . name , apiMethod ) ;
308323
309324 const syntax : IYamlSyntax = {
310- content : apiMethod . signature
325+ content : this . _formatCommentedAnnotations ( apiMethod . signature , apiMethod )
311326 } ;
312327 yamlItem . syntax = syntax ;
313328
@@ -343,8 +358,9 @@ export class YamlDocumenter {
343358 const apiProperty : IApiProperty = docItem . apiItem as IApiProperty ;
344359
345360 const syntax : IYamlSyntax = {
346- content : apiProperty . signature
361+ content : this . _formatCommentedAnnotations ( apiProperty . signature , apiProperty )
347362 } ;
363+
348364 yamlItem . syntax = syntax ;
349365
350366 if ( apiProperty . type ) {
@@ -397,6 +413,27 @@ export class YamlDocumenter {
397413 }
398414 }
399415
416+ // Prepends a string such as "/** @sealed @override */" to an item signature where appropriate.
417+ private _formatCommentedAnnotations ( signature : string , apiItem : ApiItem ) : string {
418+ const apiItemTags : { isSealed ?: boolean , isVirtual ?: boolean , isOverride ?: boolean }
419+ = apiItem as any ; // tslint:disable-line:no-any
420+
421+ const annotations : string [ ] = [ ] ;
422+ if ( apiItemTags . isSealed ) {
423+ annotations . push ( '@sealed' ) ;
424+ }
425+ if ( apiItemTags . isVirtual ) {
426+ annotations . push ( '@virtual' ) ;
427+ }
428+ if ( apiItemTags . isOverride ) {
429+ annotations . push ( '@override' ) ;
430+ }
431+ if ( annotations . length === 0 ) {
432+ return signature ;
433+ }
434+ return '/** ' + annotations . join ( ' ' ) + ' */\n' + signature ;
435+ }
436+
400437 /**
401438 * Calculate the docfx "uid" for the DocItem
402439 * Example: node-core-library.JsonFile.load
0 commit comments