@@ -104,10 +104,8 @@ export default class CodeGenerator {
104
104
}
105
105
}
106
106
107
- private openClass ( name : genspec . CodeName , docLink ?: string , superClasses ?: string , deprecation ?: string ) {
107
+ private openClass ( name : genspec . CodeName , superClasses ?: string ) {
108
108
const extendsPostfix = superClasses ? ` extends ${ superClasses } ` : '' ;
109
- const before = deprecation ? [ `@deprecated ${ deprecation } ` ] : [ ] ;
110
- this . docLink ( docLink , ...before ) ;
111
109
this . code . openBlock ( `export class ${ name . className } ${ extendsPostfix } ` ) ;
112
110
return name . className ;
113
111
}
@@ -120,7 +118,7 @@ export default class CodeGenerator {
120
118
if ( ! spec . Properties || Object . keys ( spec . Properties ) . length === 0 ) { return ; }
121
119
const name = genspec . CodeName . forResourceProperties ( resourceContext ) ;
122
120
123
- this . docLink ( spec . Documentation ) ;
121
+ this . docLink ( spec . Documentation , `Properties for defining a \` ${ resourceContext . specName ! . fqn } \`` ) ;
124
122
this . code . openBlock ( `export interface ${ name . className } ` ) ;
125
123
126
124
const conversionTable = this . emitPropsTypeProperties ( resourceContext , spec . Properties ) ;
@@ -172,6 +170,8 @@ export default class CodeGenerator {
172
170
private emitResourceType ( resourceName : genspec . CodeName , spec : schema . ResourceType , deprecated ?: genspec . CodeName ) : void {
173
171
this . beginNamespace ( resourceName ) ;
174
172
173
+ const cfnName = resourceName . specName ! . fqn ;
174
+
175
175
//
176
176
// Props Bag for this Resource
177
177
//
@@ -185,21 +185,27 @@ export default class CodeGenerator {
185
185
`"cloudformation.${ resourceName . fqn } " will be deprecated in a future release ` +
186
186
`in favor of "${ deprecated . fqn } " (see https://github.com/awslabs/aws-cdk/issues/878)` ;
187
187
188
- this . openClass ( resourceName , spec . Documentation , RESOURCE_BASE_CLASS , deprecation ) ;
188
+ this . docLink ( spec . Documentation , ...[
189
+ `A CloudFormation \`${ cfnName } \`` ,
190
+ '' ,
191
+ `@cloudformationResource ${ cfnName } ` ,
192
+ ...( deprecation ? [ `@deprecated ${ deprecation } ` ] : [ ] ) ,
193
+ ] ) ;
194
+ this . openClass ( resourceName , RESOURCE_BASE_CLASS ) ;
189
195
190
196
//
191
197
// Static inspectors.
192
198
//
193
199
194
- const resourceTypeName = `${ JSON . stringify ( resourceName . specName ! . fqn ) } ` ;
200
+ const resourceTypeName = `${ JSON . stringify ( cfnName ) } ` ;
195
201
this . code . line ( '/**' ) ;
196
202
this . code . line ( ` * The CloudFormation resource type name for this resource class.` ) ;
197
203
this . code . line ( ' */' ) ;
198
204
this . code . line ( `public static readonly resourceTypeName = ${ resourceTypeName } ;` ) ;
199
205
200
206
if ( spec . RequiredTransform ) {
201
207
this . code . line ( '/**' ) ;
202
- this . code . line ( ' * The `` Transform` ` a template must use in order to use this resource' ) ;
208
+ this . code . line ( ' * The `Transform` a template must use in order to use this resource' ) ;
203
209
this . code . line ( ' */' ) ;
204
210
this . code . line ( `public static readonly requiredTransform = ${ JSON . stringify ( spec . RequiredTransform ) } ;` ) ;
205
211
}
@@ -216,7 +222,7 @@ export default class CodeGenerator {
216
222
217
223
this . code . line ( ) ;
218
224
219
- this . docLink ( undefined , `@cloudformation_attribute ${ attributeName } ` ) ;
225
+ this . docLink ( undefined , `@cloudformationAttribute ${ attributeName } ` ) ;
220
226
const attr = genspec . attributeDefinition ( resourceName , attributeName , attributeSpec ) ;
221
227
222
228
this . code . line ( `public readonly ${ attr . propertyName } : ${ attr . attributeType } ;` ) ;
@@ -242,11 +248,11 @@ export default class CodeGenerator {
242
248
if ( tagEnum !== `${ TAG_TYPE } .NotTaggable` ) {
243
249
this . code . line ( ) ;
244
250
this . code . line ( '/**' ) ;
245
- this . code . line ( ' * The `` TagManager` ` handles setting, removing and formatting tags' ) ;
251
+ this . code . line ( ' * The `TagManager` handles setting, removing and formatting tags' ) ;
246
252
this . code . line ( ' *' ) ;
247
253
this . code . line ( ' * Tags should be managed either passing them as properties during' ) ;
248
254
this . code . line ( ' * initiation or by calling methods on this object. If both techniques are' ) ;
249
- this . code . line ( ' * used only the tags from the TagManager will be used. `` Tag` ` (aspect)' ) ;
255
+ this . code . line ( ' * used only the tags from the TagManager will be used. `Tag` (aspect)' ) ;
250
256
this . code . line ( ' * will use the manager.' ) ;
251
257
this . code . line ( ' */' ) ;
252
258
this . code . line ( `public readonly tags = new ${ TAG_MANAGER } (${ tagEnum } , ${ resourceTypeName } );` ) ;
@@ -258,11 +264,11 @@ export default class CodeGenerator {
258
264
259
265
this . code . line ( ) ;
260
266
this . code . line ( '/**' ) ;
261
- this . code . line ( ` * Creates a new ${ quoteCode ( resourceName . specName ! . fqn ) } .` ) ;
267
+ this . code . line ( ` * Create a new ${ quoteCode ( resourceName . specName ! . fqn ) } .` ) ;
262
268
this . code . line ( ' *' ) ;
263
- this . code . line ( ` * @param scope scope in which this resource is defined` ) ;
264
- this . code . line ( ` * @param id scoped id of the resource` ) ;
265
- this . code . line ( ` * @param props resource properties` ) ;
269
+ this . code . line ( ` * @param scope - scope in which this resource is defined` ) ;
270
+ this . code . line ( ` * @param id - scoped id of the resource` ) ;
271
+ this . code . line ( ` * @param props - resource properties` ) ;
266
272
this . code . line ( ' */' ) ;
267
273
const optionalProps = spec . Properties && ! Object . values ( spec . Properties ) . some ( p => p . Required || false ) ;
268
274
const propsArgument = propsType ? `, props${ optionalProps ? '?' : '' } : ${ propsType . className } ` : '' ;
@@ -362,7 +368,7 @@ export default class CodeGenerator {
362
368
this . code . line ( '/**' ) ;
363
369
this . code . line ( ` * Renders the AWS CloudFormation properties of an ${ quoteCode ( typeName . specName ! . fqn ) } resource` ) ;
364
370
this . code . line ( ' *' ) ;
365
- this . code . line ( ` * @param properties the TypeScript properties of a ${ quoteCode ( typeName . className ) } ` ) ;
371
+ this . code . line ( ` * @param properties - the TypeScript properties of a ${ quoteCode ( typeName . className ) } ` ) ;
366
372
this . code . line ( ' *' ) ;
367
373
this . code . line ( ` * @returns the AWS CloudFormation properties of an ${ quoteCode ( typeName . specName ! . fqn ) } resource.` ) ;
368
374
this . code . line ( ' */' ) ;
@@ -448,7 +454,7 @@ export default class CodeGenerator {
448
454
this . code . line ( '/**' ) ;
449
455
this . code . line ( ` * Determine whether the given properties match those of a ${ quoteCode ( typeName . className ) } ` ) ;
450
456
this . code . line ( ' *' ) ;
451
- this . code . line ( ` * @param properties the TypeScript properties of a ${ quoteCode ( typeName . className ) } ` ) ;
457
+ this . code . line ( ` * @param properties - the TypeScript properties of a ${ quoteCode ( typeName . className ) } ` ) ;
452
458
this . code . line ( ' *' ) ;
453
459
this . code . line ( ' * @returns the result of the validation.' ) ;
454
460
this . code . line ( ' */' ) ;
@@ -622,9 +628,9 @@ export default class CodeGenerator {
622
628
private docLink ( link : string | undefined , ...before : string [ ] ) {
623
629
if ( ! link && before . length === 0 ) { return ; }
624
630
this . code . line ( '/**' ) ;
625
- before . forEach ( line => this . code . line ( ` * ${ line } ` ) ) ;
631
+ before . forEach ( line => this . code . line ( ` * ${ line } ` . trimRight ( ) ) ) ;
626
632
if ( link ) {
627
- this . code . line ( ` * @link ${ link } ` ) ;
633
+ this . code . line ( ` * @see ${ link } ` ) ;
628
634
}
629
635
this . code . line ( ' */' ) ;
630
636
return ;
@@ -639,14 +645,14 @@ export default class CodeGenerator {
639
645
640
646
/**
641
647
* Quotes a code name for inclusion in a JSDoc comment, so it will render properly
642
- * in the Sphinx output.
648
+ * in the Markdown output.
643
649
*
644
650
* @param code a code name to be quoted.
645
651
*
646
652
* @returns the code name surrounded by double backticks.
647
653
*/
648
654
function quoteCode ( code : string ) : string {
649
- return '`` ' + code + '` `' ;
655
+ return '`' + code + '`' ;
650
656
}
651
657
652
658
function tokenizableType ( alternatives : string [ ] ) {
0 commit comments