jsii 6.0.22-dev.0 → 7.1.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assembler.d.ts +254 -196
- package/lib/assembler.js +2105 -2327
- package/lib/assembler.js.map +1 -1
- package/lib/case.js.map +1 -1
- package/lib/common/find-utils.js.map +1 -1
- package/lib/common/index.d.ts +1 -1
- package/lib/common/index.js +2 -1
- package/lib/common/index.js.map +1 -1
- package/lib/common/symbol-id.d.ts +23 -4
- package/lib/common/symbol-id.js +13 -9
- package/lib/common/symbol-id.js.map +1 -1
- package/lib/compiler-host.d.ts +60 -0
- package/lib/compiler-host.js +201 -0
- package/lib/compiler-host.js.map +1 -0
- package/lib/compiler.d.ts +74 -62
- package/lib/compiler.js +332 -254
- package/lib/compiler.js.map +1 -1
- package/lib/diagnostic.d.ts +34 -0
- package/lib/diagnostic.js +141 -0
- package/lib/diagnostic.js.map +1 -0
- package/lib/emitter.d.ts +40 -10
- package/lib/emitter.js +188 -0
- package/lib/emitter.js.map +1 -1
- package/lib/helpers.d.ts +1 -1
- package/lib/helpers.js +2 -2
- package/lib/helpers.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/jsii-diagnostic.d.ts +27 -22
- package/lib/jsii-diagnostic.js +22 -38
- package/lib/jsii-diagnostic.js.map +1 -1
- package/lib/literate.js.map +1 -1
- package/lib/main.js +3 -2
- package/lib/main.js.map +1 -1
- package/lib/project-info.d.ts +23 -4
- package/lib/project-info.js +5 -5
- package/lib/project-info.js.map +1 -1
- package/lib/support-types.d.ts +2 -0
- package/lib/support-types.js +3 -0
- package/lib/support-types.js.map +1 -0
- package/lib/support.js.map +1 -1
- package/lib/tsconfig/compiler-options.d.ts +12 -46
- package/lib/tsconfig/compiler-options.js +45 -87
- package/lib/tsconfig/compiler-options.js.map +1 -1
- package/lib/tsconfig/index.d.ts +24 -5
- package/lib/tsconfig/index.js.map +1 -1
- package/lib/tsconfig/read.d.ts +15 -0
- package/lib/tsconfig/read.js +196 -0
- package/lib/tsconfig/read.js.map +1 -0
- package/lib/tsconfig/rule-set-format.js.map +1 -1
- package/lib/tsconfig/rulesets/configurable-options.js.map +1 -1
- package/lib/tsconfig/rulesets/deprecated-options.js.map +1 -1
- package/lib/tsconfig/rulesets/generated.public.js.map +1 -1
- package/lib/tsconfig/rulesets/incompatible-options.js.map +1 -1
- package/lib/tsconfig/rulesets/jsii-configured-options.js.map +1 -1
- package/lib/tsconfig/rulesets/minimal.public.js.map +1 -1
- package/lib/tsconfig/rulesets/strict-family-options.js.map +1 -1
- package/lib/tsconfig/rulesets/strict.public.js.map +1 -1
- package/lib/tsconfig/tsconfig-validator.js +2 -50
- package/lib/tsconfig/tsconfig-validator.js.map +1 -1
- package/lib/tsconfig/validator.js.map +1 -1
- package/lib/type-analysis.js.map +1 -1
- package/lib/type-reference.js.map +1 -1
- package/lib/type-visitor.js.map +1 -1
- package/lib/utils.d.ts +6 -6
- package/lib/utils.js +8 -13
- package/lib/utils.js.map +1 -1
- package/lib/version.d.ts +3 -3
- package/lib/version.js +4 -4
- package/lib/version.js.map +1 -1
- package/lib/warnings.d.ts +2 -2
- package/lib/warnings.js +3 -77
- package/lib/warnings.js.map +1 -1
- package/package.json +15 -11
- package/scripts/ts7-compare-jsii.mjs +101 -0
- package/lib/directives.d.ts +0 -24
- package/lib/directives.js +0 -139
- package/lib/directives.js.map +0 -1
- package/lib/docs.d.ts +0 -64
- package/lib/docs.js +0 -293
- package/lib/docs.js.map +0 -1
- package/lib/node-bindings.d.ts +0 -19
- package/lib/node-bindings.js +0 -49
- package/lib/node-bindings.js.map +0 -1
- package/lib/reserved-words.d.ts +0 -6
- package/lib/reserved-words.js +0 -258
- package/lib/reserved-words.js.map +0 -1
- package/lib/sets.d.ts +0 -16
- package/lib/sets.js +0 -41
- package/lib/sets.js.map +0 -1
- package/lib/transforms/deprecated-remover.d.ts +0 -44
- package/lib/transforms/deprecated-remover.js +0 -545
- package/lib/transforms/deprecated-remover.js.map +0 -1
- package/lib/transforms/deprecation-warnings.d.ts +0 -37
- package/lib/transforms/deprecation-warnings.js +0 -616
- package/lib/transforms/deprecation-warnings.js.map +0 -1
- package/lib/transforms/runtime-info.d.ts +0 -39
- package/lib/transforms/runtime-info.js +0 -128
- package/lib/transforms/runtime-info.js.map +0 -1
- package/lib/transforms/utils.d.ts +0 -11
- package/lib/transforms/utils.js +0 -31
- package/lib/transforms/utils.js.map +0 -1
- package/lib/type-tracker.d.ts +0 -13
- package/lib/type-tracker.js +0 -67
- package/lib/type-tracker.js.map +0 -1
- package/lib/validator.d.ts +0 -19
- package/lib/validator.js +0 -602
- package/lib/validator.js.map +0 -1
package/package.json
CHANGED
|
@@ -34,12 +34,14 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@actions/core": "^3",
|
|
36
36
|
"@actions/github": "^9",
|
|
37
|
+
"@swc/core": "^1.16.22",
|
|
38
|
+
"@swc/jest": "^0.2.39",
|
|
37
39
|
"@types/clone": "^2.1.4",
|
|
38
40
|
"@types/deep-equal": "^1.0.4",
|
|
39
41
|
"@types/glob": "^8.1.0",
|
|
40
42
|
"@types/jest": "^29.5.14",
|
|
41
43
|
"@types/lockfile": "^1.0.4",
|
|
42
|
-
"@types/node": "^
|
|
44
|
+
"@types/node": "^22",
|
|
43
45
|
"@types/semver": "^7.8.0",
|
|
44
46
|
"@types/tar": "^6.1.13",
|
|
45
47
|
"@typescript-eslint/eslint-plugin": "^8",
|
|
@@ -62,13 +64,13 @@
|
|
|
62
64
|
"prettier": "^2.8.8",
|
|
63
65
|
"projen": "^0.104.27",
|
|
64
66
|
"tar": "^7.5.22",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"tsx": "^4.23.15"
|
|
67
|
+
"tsx": "^4.23.15",
|
|
68
|
+
"typescript": "~6.0"
|
|
68
69
|
},
|
|
69
70
|
"dependencies": {
|
|
70
71
|
"@jsii/check-node": "1.142.0",
|
|
71
72
|
"@jsii/spec": "1.142.0",
|
|
73
|
+
"@typescript/native": "npm:typescript@7.1.0-beta",
|
|
72
74
|
"case": "^1.6.3",
|
|
73
75
|
"chalk": "^4",
|
|
74
76
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -77,16 +79,15 @@
|
|
|
77
79
|
"semver-intersect": "^1.5.0",
|
|
78
80
|
"sort-json": "^2.0.1",
|
|
79
81
|
"spdx-license-list": "^6.12.0",
|
|
80
|
-
"typescript": "~6.0",
|
|
81
82
|
"yargs": "^17.7.3"
|
|
82
83
|
},
|
|
83
84
|
"engines": {
|
|
84
|
-
"node": ">=
|
|
85
|
+
"node": ">= 22.12.0"
|
|
85
86
|
},
|
|
86
87
|
"devEngines": {
|
|
87
88
|
"packageManager": {
|
|
88
89
|
"name": "yarn",
|
|
89
|
-
"version": "
|
|
90
|
+
"version": "4.18.1",
|
|
90
91
|
"onFail": "ignore"
|
|
91
92
|
}
|
|
92
93
|
},
|
|
@@ -96,8 +97,8 @@
|
|
|
96
97
|
"publishConfig": {
|
|
97
98
|
"access": "public"
|
|
98
99
|
},
|
|
99
|
-
"version": "
|
|
100
|
-
"packageManager": "yarn@4.
|
|
100
|
+
"version": "7.1.0-dev.1",
|
|
101
|
+
"packageManager": "yarn@4.18.1",
|
|
101
102
|
"types": "lib/index.d.ts",
|
|
102
103
|
"exports": {
|
|
103
104
|
".": "./lib/index.js",
|
|
@@ -105,6 +106,9 @@
|
|
|
105
106
|
"./package.json": "./package.json",
|
|
106
107
|
"./common": "./lib/common/index.js"
|
|
107
108
|
},
|
|
108
|
-
"
|
|
109
|
-
|
|
109
|
+
"imports": {
|
|
110
|
+
"#typescript": "@typescript/native",
|
|
111
|
+
"#typescript/*": "@typescript/native/*"
|
|
112
|
+
},
|
|
113
|
+
"//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"yarn projen\"."
|
|
110
114
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// ts7-compare-jsii: structural diff of the type space of two .jsii assemblies.
|
|
2
|
+
//
|
|
3
|
+
// Used as the parity gate for the experimental ts7 backend: build a package
|
|
4
|
+
// with the default backend and with JSII_COMPILER_BACKEND=ts7, then diff.
|
|
5
|
+
// Compared per type: kind, base, interfaces, abstract/datatype flags, symbolId,
|
|
6
|
+
// enum member names, and every property/method/initializer signature including
|
|
7
|
+
// parameter documentation and the stability/deprecated/default doc tags.
|
|
8
|
+
// Not compared: assembly header fields, locationInModule, and free-text member
|
|
9
|
+
// summaries/remarks (see normMember below).
|
|
10
|
+
// Usage: node ts7-compare-jsii.mjs <reference.jsii> <generated.jsii>
|
|
11
|
+
import * as fs from 'node:fs';
|
|
12
|
+
|
|
13
|
+
const ref = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
|
|
14
|
+
const gen = JSON.parse(fs.readFileSync(process.argv[3], 'utf8'));
|
|
15
|
+
|
|
16
|
+
const report = { matchedTypes: 0, missingTypes: [], extraTypes: [], memberDiffs: [], fieldDiffs: [], membersTotal: 0, membersMatched: 0 };
|
|
17
|
+
|
|
18
|
+
const refTypes = ref.types ?? {};
|
|
19
|
+
const genTypes = gen.types ?? {};
|
|
20
|
+
|
|
21
|
+
for (const fqn of Object.keys(refTypes)) if (!genTypes[fqn]) report.missingTypes.push(fqn);
|
|
22
|
+
for (const fqn of Object.keys(genTypes)) if (!refTypes[fqn]) report.extraTypes.push(fqn);
|
|
23
|
+
|
|
24
|
+
function canon(x) {
|
|
25
|
+
if (Array.isArray(x)) return x.map(canon);
|
|
26
|
+
if (x && typeof x === 'object' && x.union && Array.isArray(x.union.types)) {
|
|
27
|
+
// union member order is semantically insignificant; normalize for comparison
|
|
28
|
+
const types = x.union.types.map(canon).sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
|
|
29
|
+
return { ...Object.fromEntries(Object.entries(x).filter(([k]) => k !== 'union').map(([k, v]) => [k, canon(v)])), union: { types } };
|
|
30
|
+
}
|
|
31
|
+
if (x && typeof x === 'object') {
|
|
32
|
+
const o = {};
|
|
33
|
+
for (const k of Object.keys(x).sort()) o[k] = canon(x[k]);
|
|
34
|
+
return o;
|
|
35
|
+
}
|
|
36
|
+
return x;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function normMember(m) {
|
|
40
|
+
const c = JSON.parse(JSON.stringify(m));
|
|
41
|
+
delete c.locationInModule;
|
|
42
|
+
delete c.overrides;
|
|
43
|
+
if (c.docs) {
|
|
44
|
+
// compare only presence of summary and key tags
|
|
45
|
+
c.docs = Object.fromEntries(Object.entries(c.docs).filter(([k]) => ['default', 'deprecated', 'stability'].includes(k)));
|
|
46
|
+
if (!Object.keys(c.docs).length) delete c.docs;
|
|
47
|
+
}
|
|
48
|
+
return c;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function diffMembers(fqn, kind, refList = [], genList = []) {
|
|
52
|
+
const refMap = new Map(refList.map((m) => [m.name, m]));
|
|
53
|
+
const genMap = new Map(genList.map((m) => [m.name, m]));
|
|
54
|
+
for (const [name, rm] of refMap) {
|
|
55
|
+
report.membersTotal++;
|
|
56
|
+
const gm = genMap.get(name);
|
|
57
|
+
if (!gm) { report.memberDiffs.push(`${fqn} ${kind} ${name}: MISSING in generated`); continue; }
|
|
58
|
+
const a = JSON.stringify(canon(normMember(rm)));
|
|
59
|
+
const b = JSON.stringify(canon(normMember(gm)));
|
|
60
|
+
if (a !== b) report.memberDiffs.push(`${fqn} ${kind} ${name}: DIFFER\n ref: ${a}\n gen: ${b}`);
|
|
61
|
+
else report.membersMatched++;
|
|
62
|
+
}
|
|
63
|
+
for (const name of genMap.keys()) {
|
|
64
|
+
if (!refMap.has(name)) report.memberDiffs.push(`${fqn} ${kind} ${name}: EXTRA in generated`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (const [fqn, rt] of Object.entries(refTypes)) {
|
|
69
|
+
const gt = genTypes[fqn];
|
|
70
|
+
if (!gt) continue;
|
|
71
|
+
report.matchedTypes++;
|
|
72
|
+
for (const field of ['kind', 'base', 'abstract', 'datatype', 'symbolId']) {
|
|
73
|
+
const a = JSON.stringify(rt[field]);
|
|
74
|
+
const b = JSON.stringify(gt[field]);
|
|
75
|
+
if (a !== b) report.fieldDiffs.push(`${fqn}.${field}: ref=${a} gen=${b}`);
|
|
76
|
+
}
|
|
77
|
+
const ri = JSON.stringify((rt.interfaces ?? []).slice().sort());
|
|
78
|
+
const gi = JSON.stringify((gt.interfaces ?? []).slice().sort());
|
|
79
|
+
if (ri !== gi) report.fieldDiffs.push(`${fqn}.interfaces: ref=${ri} gen=${gi}`);
|
|
80
|
+
diffMembers(fqn, 'prop', rt.properties, gt.properties);
|
|
81
|
+
diffMembers(fqn, 'method', rt.methods, gt.methods);
|
|
82
|
+
if (rt.kind === 'enum') {
|
|
83
|
+
const rm = JSON.stringify((rt.members ?? []).map((m) => m.name).sort());
|
|
84
|
+
const gm = JSON.stringify((gt.members ?? []).map((m) => m.name).sort());
|
|
85
|
+
if (rm !== gm) report.fieldDiffs.push(`${fqn}.members: ref=${rm} gen=${gm}`);
|
|
86
|
+
}
|
|
87
|
+
if (rt.initializer || gt.initializer) {
|
|
88
|
+
diffMembers(fqn, 'initializer', rt.initializer ? [{ ...rt.initializer, name: '<init>' }] : [], gt.initializer ? [{ ...gt.initializer, name: '<init>' }] : []);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const MAX = Number(process.env.MAX_DIFFS ?? 30);
|
|
93
|
+
console.log(`=== compare summary ===`);
|
|
94
|
+
console.log(`types: ref=${Object.keys(refTypes).length} gen=${Object.keys(genTypes).length} matched=${report.matchedTypes}`);
|
|
95
|
+
console.log(`missing: ${report.missingTypes.length} ${JSON.stringify(report.missingTypes.slice(0, 20))}`);
|
|
96
|
+
console.log(`extra: ${report.extraTypes.length} ${JSON.stringify(report.extraTypes.slice(0, 20))}`);
|
|
97
|
+
console.log(`members: ${report.membersMatched}/${report.membersTotal} identical (${(report.membersMatched / Math.max(1, report.membersTotal) * 100).toFixed(1)}%)`);
|
|
98
|
+
console.log(`field diffs: ${report.fieldDiffs.length}`);
|
|
99
|
+
for (const d of report.fieldDiffs.slice(0, MAX)) console.log(` - ${d}`);
|
|
100
|
+
console.log(`member diffs: ${report.memberDiffs.length}`);
|
|
101
|
+
for (const d of report.memberDiffs.slice(0, MAX)) console.log(` - ${d}`);
|
package/lib/directives.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript';
|
|
2
|
-
import { JsiiDiagnostic } from './jsii-diagnostic';
|
|
3
|
-
/**
|
|
4
|
-
* TSDoc-style directives that can be attached to a symbol.
|
|
5
|
-
*/
|
|
6
|
-
export declare class Directives {
|
|
7
|
-
#private;
|
|
8
|
-
/**
|
|
9
|
-
* Obtains the `Directives` for a given TypeScript AST node.
|
|
10
|
-
*
|
|
11
|
-
* @param node the node for which directives are requested.
|
|
12
|
-
* @param onDiagnostic a callback invoked whenever a diagnostic message is
|
|
13
|
-
* emitted when parsing directives.
|
|
14
|
-
*/
|
|
15
|
-
static of(node: ts.Node, onDiagnostic: (diag: JsiiDiagnostic) => void): Directives;
|
|
16
|
-
/** Whether the node has the `@jsii ignore` directive set. */
|
|
17
|
-
readonly ignore?: ts.JSDocComment | ts.JSDocTag;
|
|
18
|
-
/** Whether the node has the `@jsii struct` directive set. */
|
|
19
|
-
readonly struct?: ts.JSDocComment | ts.JSDocTag;
|
|
20
|
-
/** Suppression codes from `@jsii suppress <code>` directives. */
|
|
21
|
-
readonly suppressions: readonly string[];
|
|
22
|
-
private constructor();
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=directives.d.ts.map
|
package/lib/directives.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Directives = void 0;
|
|
37
|
-
const ts = __importStar(require("typescript"));
|
|
38
|
-
const jsii_diagnostic_1 = require("./jsii-diagnostic");
|
|
39
|
-
/**
|
|
40
|
-
* TSDoc-style directives that can be attached to a symbol.
|
|
41
|
-
*/
|
|
42
|
-
class Directives {
|
|
43
|
-
/**
|
|
44
|
-
* Obtains the `Directives` for a given TypeScript AST node.
|
|
45
|
-
*
|
|
46
|
-
* @param node the node for which directives are requested.
|
|
47
|
-
* @param onDiagnostic a callback invoked whenever a diagnostic message is
|
|
48
|
-
* emitted when parsing directives.
|
|
49
|
-
*/
|
|
50
|
-
static of(node, onDiagnostic) {
|
|
51
|
-
const found = Directives.#CACHE.get(node);
|
|
52
|
-
if (found != null) {
|
|
53
|
-
return found;
|
|
54
|
-
}
|
|
55
|
-
const directives = new Directives(node, onDiagnostic);
|
|
56
|
-
Directives.#CACHE.set(node, directives);
|
|
57
|
-
return directives;
|
|
58
|
-
}
|
|
59
|
-
static #CACHE = new WeakMap();
|
|
60
|
-
/** Whether the node has the `@internal` JSDoc tag. */
|
|
61
|
-
tsInternal;
|
|
62
|
-
/** Whether the node has the `@jsii ignore` directive set. */
|
|
63
|
-
ignore;
|
|
64
|
-
/** Whether the node has the `@jsii struct` directive set. */
|
|
65
|
-
struct;
|
|
66
|
-
/** Suppression codes from `@jsii suppress <code>` directives. */
|
|
67
|
-
suppressions = [];
|
|
68
|
-
constructor(node, onDiagnostic) {
|
|
69
|
-
const suppressions = [];
|
|
70
|
-
for (const tag of ts.getJSDocTags(node)) {
|
|
71
|
-
switch (tag.tagName.text) {
|
|
72
|
-
case 'internal':
|
|
73
|
-
this.tsInternal ??= tag;
|
|
74
|
-
break;
|
|
75
|
-
case 'jsii':
|
|
76
|
-
const comments = getComments(tag);
|
|
77
|
-
if (comments.length === 0) {
|
|
78
|
-
onDiagnostic(jsii_diagnostic_1.JsiiDiagnostic.JSII_2000_MISSING_DIRECTIVE_ARGUMENT.create(tag));
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
for (const { text, jsdocNode } of comments) {
|
|
82
|
-
const [subcommand, ...rest] = text.split(/\s+/);
|
|
83
|
-
switch (subcommand) {
|
|
84
|
-
case 'ignore':
|
|
85
|
-
this.ignore ??= jsdocNode;
|
|
86
|
-
break;
|
|
87
|
-
case 'suppress': {
|
|
88
|
-
const code = rest[0];
|
|
89
|
-
if (code) {
|
|
90
|
-
suppressions.push(code);
|
|
91
|
-
}
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
default:
|
|
95
|
-
onDiagnostic(jsii_diagnostic_1.JsiiDiagnostic.JSII_2999_UNKNOWN_DIRECTIVE.create(jsdocNode, text));
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
break;
|
|
100
|
-
default: // Ignore
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
this.suppressions = suppressions;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
exports.Directives = Directives;
|
|
107
|
-
function getComments(tag) {
|
|
108
|
-
if (tag.comment == null) {
|
|
109
|
-
return [];
|
|
110
|
-
}
|
|
111
|
-
if (typeof tag.comment === 'string') {
|
|
112
|
-
const text = tag.comment.trim();
|
|
113
|
-
return text
|
|
114
|
-
? text.split(/[\n,]/).flatMap((line) => {
|
|
115
|
-
line = line.trim();
|
|
116
|
-
return line ? [{ text: line, jsdocNode: tag }] : [];
|
|
117
|
-
})
|
|
118
|
-
: [];
|
|
119
|
-
}
|
|
120
|
-
// Possible per the type signature in the compiler, however not sure in which conditions.
|
|
121
|
-
return tag.comment.flatMap((jsdocNode) => {
|
|
122
|
-
let text;
|
|
123
|
-
switch (jsdocNode.kind) {
|
|
124
|
-
case ts.SyntaxKind.JSDocText:
|
|
125
|
-
text = jsdocNode.text;
|
|
126
|
-
break;
|
|
127
|
-
case ts.SyntaxKind.JSDocLink:
|
|
128
|
-
case ts.SyntaxKind.JSDocLinkCode:
|
|
129
|
-
case ts.SyntaxKind.JSDocLinkPlain:
|
|
130
|
-
text = jsdocNode.name
|
|
131
|
-
? `${jsdocNode.name.getText(jsdocNode.name.getSourceFile())}: ${jsdocNode.text}`
|
|
132
|
-
: jsdocNode.text;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
text = text.trim();
|
|
136
|
-
return text ? [{ text, jsdocNode }] : [];
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=directives.js.map
|
package/lib/directives.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../src/directives.ts"],"names":[],"mappings":"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","sourcesContent":["import * as ts from 'typescript';\nimport { JsiiDiagnostic } from './jsii-diagnostic';\n\n/**\n * TSDoc-style directives that can be attached to a symbol.\n */\nexport class Directives {\n /**\n * Obtains the `Directives` for a given TypeScript AST node.\n *\n * @param node the node for which directives are requested.\n * @param onDiagnostic a callback invoked whenever a diagnostic message is\n * emitted when parsing directives.\n */\n public static of(node: ts.Node, onDiagnostic: (diag: JsiiDiagnostic) => void): Directives {\n const found = Directives.#CACHE.get(node);\n if (found != null) {\n return found;\n }\n\n const directives = new Directives(node, onDiagnostic);\n Directives.#CACHE.set(node, directives);\n return directives;\n }\n\n static readonly #CACHE = new WeakMap<ts.Node, Directives>();\n\n /** Whether the node has the `@internal` JSDoc tag. */\n public readonly tsInternal?: ts.JSDocTag;\n /** Whether the node has the `@jsii ignore` directive set. */\n public readonly ignore?: ts.JSDocComment | ts.JSDocTag;\n /** Whether the node has the `@jsii struct` directive set. */\n public readonly struct?: ts.JSDocComment | ts.JSDocTag;\n /** Suppression codes from `@jsii suppress <code>` directives. */\n public readonly suppressions: readonly string[] = [];\n\n private constructor(node: ts.Node, onDiagnostic: (diag: JsiiDiagnostic) => void) {\n const suppressions: string[] = [];\n for (const tag of ts.getJSDocTags(node)) {\n switch (tag.tagName.text) {\n case 'internal':\n this.tsInternal ??= tag;\n break;\n case 'jsii':\n const comments = getComments(tag);\n if (comments.length === 0) {\n onDiagnostic(JsiiDiagnostic.JSII_2000_MISSING_DIRECTIVE_ARGUMENT.create(tag));\n continue;\n }\n for (const { text, jsdocNode } of comments) {\n const [subcommand, ...rest] = text.split(/\\s+/);\n switch (subcommand) {\n case 'ignore':\n this.ignore ??= jsdocNode;\n break;\n case 'suppress': {\n const code = rest[0];\n if (code) {\n suppressions.push(code);\n }\n break;\n }\n default:\n onDiagnostic(JsiiDiagnostic.JSII_2999_UNKNOWN_DIRECTIVE.create(jsdocNode, text));\n break;\n }\n }\n break;\n default: // Ignore\n }\n }\n this.suppressions = suppressions;\n }\n}\n\nfunction getComments(tag: ts.JSDocTag): Comment[] {\n if (tag.comment == null) {\n return [];\n }\n\n if (typeof tag.comment === 'string') {\n const text = tag.comment.trim();\n return text\n ? text.split(/[\\n,]/).flatMap((line) => {\n line = line.trim();\n return line ? [{ text: line, jsdocNode: tag }] : [];\n })\n : [];\n }\n\n // Possible per the type signature in the compiler, however not sure in which conditions.\n return tag.comment.flatMap((jsdocNode): Comment[] => {\n let text: string;\n switch (jsdocNode.kind) {\n case ts.SyntaxKind.JSDocText:\n text = jsdocNode.text;\n break;\n case ts.SyntaxKind.JSDocLink:\n case ts.SyntaxKind.JSDocLinkCode:\n case ts.SyntaxKind.JSDocLinkPlain:\n text = jsdocNode.name\n ? `${jsdocNode.name.getText(jsdocNode.name.getSourceFile())}: ${jsdocNode.text}`\n : jsdocNode.text;\n break;\n }\n text = text.trim();\n return text ? [{ text, jsdocNode }] : [];\n });\n}\n\ninterface Comment {\n readonly text: string;\n readonly jsdocNode: ts.JSDocComment | ts.JSDocTag;\n}\n"]}
|
package/lib/docs.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Doc Comment parsing
|
|
3
|
-
*
|
|
4
|
-
* I tried using TSDoc here.
|
|
5
|
-
*
|
|
6
|
-
* Pro:
|
|
7
|
-
* - Future standard.
|
|
8
|
-
* - Does validating parsing and complains on failure.
|
|
9
|
-
* - Has a more flexible interpretation of the @example tag (starts in text mode).
|
|
10
|
-
*
|
|
11
|
-
* Con:
|
|
12
|
-
* - Different tags from JSDoc (@defaultValue instead of @default, "@param name
|
|
13
|
-
* description" instead "@param name description".
|
|
14
|
-
* - @example tag has a different interpretation than VSCode and JSDoc
|
|
15
|
-
* (VSCode/JSDoc starts in code mode), which is confusing for syntax
|
|
16
|
-
* highlighting in the editor.
|
|
17
|
-
* - Allows no unknown tags.
|
|
18
|
-
* - Wants to be in charge of parsing TypeScript, integrating into other build is
|
|
19
|
-
* possible but harder.
|
|
20
|
-
* - Parse to a DOM with no easy way to roundtrip back to equivalent MarkDown.
|
|
21
|
-
*
|
|
22
|
-
* Especially the last point: while parsing to and storing the parsed docs DOM
|
|
23
|
-
* in the jsii assembly is superior in the long term (for example for
|
|
24
|
-
* converting to different output formats, JavaDoc, C# docs, refdocs which all
|
|
25
|
-
* accept slightly different syntaxes), right now we can get 80% of the bang
|
|
26
|
-
* for 10% of the buck by just reading, storing and reproducing MarkDown, which
|
|
27
|
-
* is Readable Enough(tm).
|
|
28
|
-
*
|
|
29
|
-
* If we ever want to attempt TSDoc again, this would be a good place to look at:
|
|
30
|
-
*
|
|
31
|
-
* https://github.com/Microsoft/tsdoc/blob/master/api-demo/src/advancedDemo.ts
|
|
32
|
-
*/
|
|
33
|
-
import * as spec from '@jsii/spec';
|
|
34
|
-
import * as ts from 'typescript';
|
|
35
|
-
/**
|
|
36
|
-
* Parse all doc comments that apply to a symbol into JSIIDocs format
|
|
37
|
-
*/
|
|
38
|
-
export declare function parseSymbolDocumentation(sym: ts.Symbol, typeChecker: ts.TypeChecker): DocsParsingResult;
|
|
39
|
-
/**
|
|
40
|
-
* Return the list of parameter names that are referenced in the docstring for this symbol
|
|
41
|
-
*/
|
|
42
|
-
export declare function getReferencedDocParams(sym: ts.Symbol): string[];
|
|
43
|
-
export interface DocsParsingResult {
|
|
44
|
-
docs: spec.Docs;
|
|
45
|
-
hints: TypeSystemHints;
|
|
46
|
-
diagnostics?: string[];
|
|
47
|
-
}
|
|
48
|
-
export interface TypeSystemHints {
|
|
49
|
-
/**
|
|
50
|
-
* Only present on interfaces. This indicates that interface must be handled as a struct/data type
|
|
51
|
-
* even through it's name starts with a capital letter `I`.
|
|
52
|
-
*/
|
|
53
|
-
struct?: boolean;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Split the doc comment into summary and remarks
|
|
57
|
-
*
|
|
58
|
-
* Normally, we'd expect people to split into a summary line and detail lines using paragraph
|
|
59
|
-
* markers. However, a LOT of people do not do this, and just paste a giant comment block into
|
|
60
|
-
* the docstring. If we detect that situation, we will try and extract the first sentence (using
|
|
61
|
-
* a period) as the summary.
|
|
62
|
-
*/
|
|
63
|
-
export declare function splitSummary(docBlock: string | undefined): [string | undefined, string | undefined];
|
|
64
|
-
//# sourceMappingURL=docs.d.ts.map
|