Skip to content

Commit 9cfd867

Browse files
authored
feat(jsii-diff): standardize doc comments, add API compatibility tool (#415)
Add parsing semantics for various common capabilities to doc comments (summary, remarks, stability and others). Add a tool uses stability annotations in the doc comments to check whether two JSII assemblies are API-compatible.
1 parent 802fe72 commit 9cfd867

File tree

178 files changed

+14801
-8145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+14801
-8145
lines changed

package-lock.json

Lines changed: 1689 additions & 4395 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/codemaker/package-lock.json

Lines changed: 509 additions & 206 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/jsii-build-tools/package-lock.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/jsii-calc-base/test/assembly.jsii

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"abstract": true,
6969
"assembly": "@scope/jsii-calc-base",
7070
"docs": {
71-
"comment": "A base class."
71+
"summary": "A base class."
7272
},
7373
"fqn": "@scope/jsii-calc-base.Base",
7474
"initializer": {
@@ -78,7 +78,7 @@
7878
"methods": [
7979
{
8080
"docs": {
81-
"return": "the name of the class (to verify native type names are created for derived classes)."
81+
"returns": "the name of the class (to verify native type names are created for derived classes)."
8282
},
8383
"name": "typeName",
8484
"returns": {
@@ -112,5 +112,5 @@
112112
}
113113
},
114114
"version": "0.8.2",
115-
"fingerprint": "rxvvJXFGzGZKodg4kjh0+uD9J3GU64sbBwcOkTFU9l8="
115+
"fingerprint": "lIcHicx5rBBxyy5vOvOqvbBGjk//8lFLX6oVx2xh5Fc="
116116
}

packages/jsii-calc-lib/lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export interface StructWithOnlyOptionals {
9191
}
9292

9393
/**
94-
* Check that enums from @scoped packages can be references.
94+
* Check that enums from \@scoped packages can be references.
9595
* See awslabs/jsii#138
9696
*/
9797
export enum EnumFromScopedModule {

packages/jsii-calc-lib/test/assembly.jsii

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"@scope/jsii-calc-lib.EnumFromScopedModule": {
9494
"assembly": "@scope/jsii-calc-lib",
9595
"docs": {
96-
"comment": "Check that enums from @scoped packages can be references.\nSee awslabs/jsii#138"
96+
"summary": "Check that enums from \\@scoped packages can be references. See awslabs/jsii#138."
9797
},
9898
"fqn": "@scope/jsii-calc-lib.EnumFromScopedModule",
9999
"kind": "enum",
@@ -110,7 +110,7 @@
110110
"@scope/jsii-calc-lib.IDoublable": {
111111
"assembly": "@scope/jsii-calc-lib",
112112
"docs": {
113-
"comment": "The general contract for a concrete number."
113+
"summary": "The general contract for a concrete number."
114114
},
115115
"fqn": "@scope/jsii-calc-lib.IDoublable",
116116
"kind": "interface",
@@ -129,15 +129,16 @@
129129
"@scope/jsii-calc-lib.IFriendly": {
130130
"assembly": "@scope/jsii-calc-lib",
131131
"docs": {
132-
"comment": "Applies to classes that are considered friendly. These classes can be greeted with\na \"hello\" or \"goodbye\" blessing and they will respond back in a fun and friendly manner."
132+
"remarks": "These classes can be greeted with\na \"hello\" or \"goodbye\" blessing and they will respond back in a fun and friendly manner.",
133+
"summary": "Applies to classes that are considered friendly."
133134
},
134135
"fqn": "@scope/jsii-calc-lib.IFriendly",
135136
"kind": "interface",
136137
"methods": [
137138
{
138139
"abstract": true,
139140
"docs": {
140-
"comment": "Say hello!"
141+
"summary": "Say hello!"
141142
},
142143
"name": "hello",
143144
"returns": {
@@ -151,7 +152,7 @@
151152
"assembly": "@scope/jsii-calc-lib",
152153
"datatype": true,
153154
"docs": {
154-
"comment": "This is the first struct we have created in jsii"
155+
"summary": "This is the first struct we have created in jsii."
155156
},
156157
"fqn": "@scope/jsii-calc-lib.MyFirstStruct",
157158
"kind": "interface",
@@ -160,7 +161,7 @@
160161
{
161162
"abstract": true,
162163
"docs": {
163-
"comment": "An awesome number value"
164+
"summary": "An awesome number value."
164165
},
165166
"immutable": true,
166167
"name": "anumber",
@@ -171,7 +172,7 @@
171172
{
172173
"abstract": true,
173174
"docs": {
174-
"comment": "A string value"
175+
"summary": "A string value."
175176
},
176177
"immutable": true,
177178
"name": "astring",
@@ -201,18 +202,18 @@
201202
"fqn": "@scope/jsii-calc-lib.Value"
202203
},
203204
"docs": {
204-
"comment": "Represents a concrete number."
205+
"summary": "Represents a concrete number."
205206
},
206207
"fqn": "@scope/jsii-calc-lib.Number",
207208
"initializer": {
208209
"docs": {
209-
"comment": "Creates a Number object."
210+
"summary": "Creates a Number object."
210211
},
211212
"initializer": true,
212213
"parameters": [
213214
{
214215
"docs": {
215-
"comment": "The number."
216+
"summary": "The number."
216217
},
217218
"name": "value",
218219
"type": {
@@ -231,7 +232,7 @@
231232
"properties": [
232233
{
233234
"docs": {
234-
"comment": "The number multiplied by 2."
235+
"summary": "The number multiplied by 2."
235236
},
236237
"immutable": true,
237238
"name": "doubleValue",
@@ -244,7 +245,7 @@
244245
},
245246
{
246247
"docs": {
247-
"comment": "The number."
248+
"summary": "The number."
248249
},
249250
"immutable": true,
250251
"name": "value",
@@ -264,7 +265,7 @@
264265
"fqn": "@scope/jsii-calc-lib.Value"
265266
},
266267
"docs": {
267-
"comment": "Represents an operation on values."
268+
"summary": "Represents an operation on values."
268269
},
269270
"fqn": "@scope/jsii-calc-lib.Operation",
270271
"initializer": {
@@ -275,7 +276,7 @@
275276
{
276277
"abstract": true,
277278
"docs": {
278-
"comment": "String representation of the value."
279+
"summary": "String representation of the value."
279280
},
280281
"name": "toString",
281282
"overrides": {
@@ -292,7 +293,7 @@
292293
"assembly": "@scope/jsii-calc-lib",
293294
"datatype": true,
294295
"docs": {
295-
"comment": "This is a struct with only optional properties."
296+
"summary": "This is a struct with only optional properties."
296297
},
297298
"fqn": "@scope/jsii-calc-lib.StructWithOnlyOptionals",
298299
"kind": "interface",
@@ -301,7 +302,7 @@
301302
{
302303
"abstract": true,
303304
"docs": {
304-
"comment": "The first optional!"
305+
"summary": "The first optional!"
305306
},
306307
"immutable": true,
307308
"name": "optional1",
@@ -337,7 +338,7 @@
337338
"fqn": "@scope/jsii-calc-base.Base"
338339
},
339340
"docs": {
340-
"comment": "Abstract class which represents a numeric value."
341+
"summary": "Abstract class which represents a numeric value."
341342
},
342343
"fqn": "@scope/jsii-calc-lib.Value",
343344
"initializer": {
@@ -347,7 +348,7 @@
347348
"methods": [
348349
{
349350
"docs": {
350-
"comment": "String representation of the value."
351+
"summary": "String representation of the value."
351352
},
352353
"name": "toString",
353354
"returns": {
@@ -360,7 +361,7 @@
360361
{
361362
"abstract": true,
362363
"docs": {
363-
"comment": "The value."
364+
"summary": "The value."
364365
},
365366
"immutable": true,
366367
"name": "value",
@@ -372,5 +373,5 @@
372373
}
373374
},
374375
"version": "0.8.2",
375-
"fingerprint": "ydArnwt9qdOM1IiBaOFzS2A7t9/+na0q+OibmkwQrEg="
376+
"fingerprint": "SDQQzBvYRO3SXfWWgpKwLDSy3EgMqP/e6rd75kblKA0="
376377
}

packages/jsii-calc/lib/compliance.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,14 +641,14 @@ export class VariadicMethod {
641641
private readonly prefix: number[];
642642

643643
/**
644-
* @param prefix a prefix that will be use for all values returned by ``#asArray``.
644+
* @param prefix a prefix that will be use for all values returned by `#asArray`.
645645
*/
646646
constructor(...prefix: number[]) {
647647
this.prefix = prefix;
648648
}
649649

650650
/**
651-
* @param first the first element of the array to be returned (after the ``prefix`` provided at construction time).
651+
* @param first the first element of the array to be returned (after the `prefix` provided at construction time).
652652
* @param others other elements to be included in the array.
653653
*/
654654
public asArray(first: number, ...others: number[]): number[] {
@@ -1283,7 +1283,7 @@ export interface LoadBalancedFargateServiceProps {
12831283
* Helps ensure the JSII kernel & runtime cooperate correctly when an un-exported instance of a class is returned with
12841284
* a declared type that is an exported interface, and the instance inherits from an exported class.
12851285
*
1286-
* @returns an instance of an un-exported class that extends ``ExportedBaseClass``, declared as ``IPrivatelyImplemented``.
1286+
* @returns an instance of an un-exported class that extends `ExportedBaseClass`, declared as `IPrivatelyImplemented`.
12871287
*
12881288
* @see https://github.com/awslabs/jsii/issues/320
12891289
*/

packages/jsii-calc/lib/documented.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Here's the first line of the TSDoc comment.
3+
*
4+
* This is the meat of the TSDoc comment. It may contain
5+
* multiple lines and multiple paragraphs.
6+
*
7+
* Multiple paragraphs are separated by an empty line.
8+
*
9+
* @stable
10+
*/
11+
export class DocumentedClass {
12+
13+
/**
14+
* Greet the indicated person.
15+
*
16+
* This will print out a friendly greeting intended for
17+
* the indicated person.
18+
*
19+
* @param greetee The person to be greeted.
20+
* @returns A number that everyone knows very well
21+
*/
22+
public greet(greetee: Greetee = {}) {
23+
process.stdout.write(`Hello, ${greetee.name || 'world'}\n`);
24+
return 42;
25+
}
26+
27+
/**
28+
* Say ¡Hola!
29+
*
30+
* @experimental
31+
*/
32+
public hola() {
33+
process.stdout.write('bonjour');
34+
}
35+
}
36+
37+
/**
38+
* These are some arguments you can pass to a method.
39+
*/
40+
export interface Greetee {
41+
/**
42+
* The name of the greetee
43+
*
44+
* @default world
45+
*/
46+
readonly name?: string;
47+
}
48+
49+
/**
50+
* Old class
51+
*
52+
* @deprecated Use the new class
53+
*/
54+
export class Old {
55+
/**
56+
* Doo wop that thing
57+
*/
58+
public doAThing() {
59+
// Nothing to do
60+
}
61+
}

packages/jsii-calc/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './calculator';
22
export * from './compliance';
3+
export * from './documented';

packages/jsii-calc/package-lock.json

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)