jsii 7.1.0-dev.3 → 7.1.0-dev.5
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 +6 -0
- package/lib/assembler.js +88 -60
- package/lib/assembler.js.map +1 -1
- package/lib/helpers.js +5 -1
- package/lib/helpers.js.map +1 -1
- package/lib/jsii-diagnostic.js +24 -2
- package/lib/jsii-diagnostic.js.map +1 -1
- package/lib/tsconfig/rulesets/configurable-options.js +2 -0
- package/lib/tsconfig/rulesets/configurable-options.js.map +1 -1
- package/lib/version.d.ts +2 -2
- package/lib/version.js +2 -2
- package/lib/version.js.map +1 -1
- package/package.json +4 -4
package/lib/assembler.d.ts
CHANGED
|
@@ -170,6 +170,12 @@ export declare class Assembler {
|
|
|
170
170
|
* violations) is not performed here.
|
|
171
171
|
*/
|
|
172
172
|
private _finalizeInheritance;
|
|
173
|
+
/**
|
|
174
|
+
* Whether an interface re-declares an inherited member with exactly the same
|
|
175
|
+
* shape, so that only its documentation differs. `overrides` already points
|
|
176
|
+
* at the nearest base interface that declares the member.
|
|
177
|
+
*/
|
|
178
|
+
private _redeclaresInterfaceMember;
|
|
173
179
|
/**
|
|
174
180
|
* Declaration rank of a type FQN for union ordering: own types by (program file
|
|
175
181
|
* order, position in file); types of dependencies before them, by name.
|
package/lib/assembler.js
CHANGED
|
@@ -105,46 +105,30 @@ function loadSubmoduleReadMe(submoduleMain, projectRoot) {
|
|
|
105
105
|
.join('\n'),
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
let i = 0;
|
|
123
|
-
while (i < text.length) {
|
|
124
|
-
if (text[i] === '<') {
|
|
125
|
-
brackets++;
|
|
126
|
-
}
|
|
127
|
-
if (text[i] === '>') {
|
|
128
|
-
brackets--;
|
|
129
|
-
}
|
|
130
|
-
i++;
|
|
131
|
-
if (!brackets) {
|
|
132
|
-
return i;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return 0;
|
|
108
|
+
/**
|
|
109
|
+
* Splits the inside of a `{@link ...}` tag into its target and label. The label
|
|
110
|
+
* follows a `|`, or the first whitespace when there is no `|`.
|
|
111
|
+
*/
|
|
112
|
+
function splitLinkTarget(body) {
|
|
113
|
+
const trimmed = body.trim();
|
|
114
|
+
const pipe = trimmed.indexOf('|');
|
|
115
|
+
if (pipe >= 0) {
|
|
116
|
+
return { target: trimmed.slice(0, pipe).trim(), label: trimmed.slice(pipe + 1).trim() };
|
|
117
|
+
}
|
|
118
|
+
const space = trimmed.search(/\s/);
|
|
119
|
+
return space < 0
|
|
120
|
+
? { target: trimmed, label: '' }
|
|
121
|
+
: { target: trimmed.slice(0, space), label: trimmed.slice(space).trim() };
|
|
137
122
|
}
|
|
138
|
-
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
return text;
|
|
123
|
+
/**
|
|
124
|
+
* Renders the `{@link}` tags in a JSDoc tag's text. Labeled links become
|
|
125
|
+
* `{@link target | label}`; unlabeled links keep the classic trailing space.
|
|
126
|
+
*/
|
|
127
|
+
function renderTagLinks(text) {
|
|
128
|
+
return text.replace(/\{@(link|linkcode|linkplain)\s+([^}]*?)\s*\}/g, (_, kind, body) => {
|
|
129
|
+
const { target, label } = splitLinkTarget(body);
|
|
130
|
+
return label ? `{@${kind} ${target} | ${label}}` : `{@${kind} ${target} }`;
|
|
131
|
+
});
|
|
148
132
|
}
|
|
149
133
|
/**
|
|
150
134
|
* Orders the constituents of a union the way the classic compiler emitted them.
|
|
@@ -401,7 +385,14 @@ class Assembler {
|
|
|
401
385
|
}
|
|
402
386
|
commentLines.push(line);
|
|
403
387
|
}
|
|
404
|
-
|
|
388
|
+
// TypeScript ends a `{@link}` at a newline and leaks the rest of its label as text, so
|
|
389
|
+
// put a label that continues on the next JSDoc line back on one line. The TypeScript 7
|
|
390
|
+
// rendering of such a link is broken, so the raw comment is used instead.
|
|
391
|
+
let rejoined = false;
|
|
392
|
+
const rawComment = commentLines.join('\n').replace(/\{@(?:link|linkcode|linkplain)\b[^}]*\n[^}]*\}/g, (link) => {
|
|
393
|
+
rejoined = true;
|
|
394
|
+
return link.replace(/\s*\n\s*/g, ' ').replace(/\s+\}$/, '}');
|
|
395
|
+
});
|
|
405
396
|
if (!/\{@link(code|plain)?\b/.test(rawComment)) {
|
|
406
397
|
return comment;
|
|
407
398
|
}
|
|
@@ -409,7 +400,7 @@ class Assembler {
|
|
|
409
400
|
let result = comment;
|
|
410
401
|
let cursor = 0;
|
|
411
402
|
let rawRendered = rawComment;
|
|
412
|
-
let allFound =
|
|
403
|
+
let allFound = !rejoined;
|
|
413
404
|
let rawCursor = 0;
|
|
414
405
|
for (const m of rawComment.matchAll(linkRe)) {
|
|
415
406
|
// Anchor the search on the (end of the) raw text preceding this link, so a
|
|
@@ -425,27 +416,26 @@ class Assembler {
|
|
|
425
416
|
const kind = m[1];
|
|
426
417
|
const after = m[2].replace(/^\s+/, '');
|
|
427
418
|
const nm = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*(?:#[A-Za-z_$][\w$]*)*/.exec(after);
|
|
419
|
+
const { target, label } = splitLinkTarget(after);
|
|
428
420
|
let classic;
|
|
429
421
|
let modern;
|
|
422
|
+
if (label) {
|
|
423
|
+
classic = `{@${kind} ${target} | ${label}}`;
|
|
424
|
+
}
|
|
425
|
+
else if (!nm || target.includes('://')) {
|
|
426
|
+
classic = `{@${kind} ${target}}`;
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
// An unresolved name (or a `#member` name, which the classic checker never
|
|
430
|
+
// resolved) keeps the classic trailing space.
|
|
431
|
+
const resolved = !nm[0].includes('#') && this._resolvesLinkName(nm[0], decl);
|
|
432
|
+
classic = resolved ? `{@${kind} ${target}}` : `{@${kind} ${target} }`;
|
|
433
|
+
}
|
|
430
434
|
if (!nm) {
|
|
431
|
-
classic = `{@${kind} ${after}}`;
|
|
432
435
|
modern = after;
|
|
433
436
|
}
|
|
434
437
|
else {
|
|
435
|
-
|
|
436
|
-
const text = after.slice(name0.length);
|
|
437
|
-
const suffix = findLinkNameEnd(text);
|
|
438
|
-
const name = name0 + text.slice(0, suffix);
|
|
439
|
-
const rest = skipSeparatorFromLinkText(text.slice(suffix));
|
|
440
|
-
const resolved = !name0.includes('#') && this._resolvesLinkName(name0, decl);
|
|
441
|
-
if (resolved) {
|
|
442
|
-
classic = `{@${kind} ${name}${rest}}`;
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
const separator = suffix === 0 || (text.charCodeAt(suffix) === 124 && !name.endsWith(' ')) ? ' ' : '';
|
|
446
|
-
classic = `{@${kind} ${name}${separator}${rest}}`;
|
|
447
|
-
}
|
|
448
|
-
modern = `${name0.replace(/#/g, '.')}${text}`;
|
|
438
|
+
modern = `${nm[0].replace(/#/g, '.')}${after.slice(nm[0].length)}`;
|
|
449
439
|
}
|
|
450
440
|
rawRendered = rawRendered.replace(m[0], classic);
|
|
451
441
|
// Re-insert the braces where the TypeScript 7 rendering of this link is.
|
|
@@ -833,7 +823,9 @@ class Assembler {
|
|
|
833
823
|
if (!isModuleFile) {
|
|
834
824
|
return result;
|
|
835
825
|
}
|
|
836
|
-
|
|
826
|
+
// The declaration handle's path is lowercased on case-insensitive file systems; the
|
|
827
|
+
// source file's name keeps the case, so paths derived from it stay relative to the root.
|
|
828
|
+
const submoduleMain = moduleSym.declarations?.[0]?.resolve(this.project)?.fileName;
|
|
837
829
|
if (submoduleMain == null) {
|
|
838
830
|
return result;
|
|
839
831
|
}
|
|
@@ -994,9 +986,46 @@ class Assembler {
|
|
|
994
986
|
implementationOf(property, type, (t) => t.properties);
|
|
995
987
|
}
|
|
996
988
|
}
|
|
989
|
+
if (spec.isInterfaceType(type) && this._redeclaresInterfaceMember(type, dereference, same)) {
|
|
990
|
+
this.usedFeatures.add('interface-member-doc-overrides');
|
|
991
|
+
}
|
|
997
992
|
}
|
|
998
993
|
return this.usedFeatures.size > 0 ? Array.from(this.usedFeatures).sort() : undefined;
|
|
999
994
|
}
|
|
995
|
+
/**
|
|
996
|
+
* Whether an interface re-declares an inherited member with exactly the same
|
|
997
|
+
* shape, so that only its documentation differs. `overrides` already points
|
|
998
|
+
* at the nearest base interface that declares the member.
|
|
999
|
+
*/
|
|
1000
|
+
_redeclaresInterfaceMember(type, dereference, same) {
|
|
1001
|
+
const baseMember = (member, pick) => {
|
|
1002
|
+
const base = member.overrides != null ? dereference(member.overrides) : undefined;
|
|
1003
|
+
return base != null && spec.isInterfaceType(base) ? pick(base)?.find((m) => m.name === member.name) : undefined;
|
|
1004
|
+
};
|
|
1005
|
+
const sameMethod = (member, base) => {
|
|
1006
|
+
const params = member.parameters ?? [];
|
|
1007
|
+
const baseParams = base.parameters ?? [];
|
|
1008
|
+
return (!!member.static === !!base.static &&
|
|
1009
|
+
!!member.async === !!base.async &&
|
|
1010
|
+
same(member.returns, base.returns) &&
|
|
1011
|
+
params.length === baseParams.length &&
|
|
1012
|
+
params.every((param, i) => same(param.type, baseParams[i].type) &&
|
|
1013
|
+
!!param.optional === !!baseParams[i].optional &&
|
|
1014
|
+
!!param.variadic === !!baseParams[i].variadic));
|
|
1015
|
+
};
|
|
1016
|
+
const sameProperty = (member, base) => !!member.static === !!base.static &&
|
|
1017
|
+
!!member.optional === !!base.optional &&
|
|
1018
|
+
!!member.immutable === !!base.immutable &&
|
|
1019
|
+
same(member.type, base.type);
|
|
1020
|
+
return ((type.methods ?? []).some((m) => {
|
|
1021
|
+
const base = baseMember(m, (t) => t.methods);
|
|
1022
|
+
return base != null && sameMethod(m, base);
|
|
1023
|
+
}) ||
|
|
1024
|
+
(type.properties ?? []).some((p) => {
|
|
1025
|
+
const base = baseMember(p, (t) => t.properties);
|
|
1026
|
+
return base != null && sameProperty(p, base);
|
|
1027
|
+
}));
|
|
1028
|
+
}
|
|
1000
1029
|
/**
|
|
1001
1030
|
* Declaration rank of a type FQN for union ordering: own types by (program file
|
|
1002
1031
|
* order, position in file); types of dependencies before them, by name.
|
|
@@ -1874,7 +1903,7 @@ class Assembler {
|
|
|
1874
1903
|
docs.summary = summary;
|
|
1875
1904
|
}
|
|
1876
1905
|
for (const tag of tags) {
|
|
1877
|
-
const tagText = tag.text
|
|
1906
|
+
const tagText = renderTagLinks(tag.text);
|
|
1878
1907
|
switch (tag.name) {
|
|
1879
1908
|
case 'default':
|
|
1880
1909
|
docs.default = tagText.trim();
|
|
@@ -2192,8 +2221,7 @@ class Assembler {
|
|
|
2192
2221
|
if (tag.name === 'param' || tag.name === 'jsii') {
|
|
2193
2222
|
continue;
|
|
2194
2223
|
}
|
|
2195
|
-
let tagText = typeof tag.text === 'string' ? tag.text : (tag.text ?? []).map((p) => p.text).join('');
|
|
2196
|
-
tagText = tagText.replace(/\{@link\s+([^}]*?)\s*\}/g, '{@link $1 }');
|
|
2224
|
+
let tagText = renderTagLinks(typeof tag.text === 'string' ? tag.text : (tag.text ?? []).map((p) => p.text).join(''));
|
|
2197
2225
|
if (tag.name === 'see' && /^[^\s$A-Za-z_{]/.test(tagText)) {
|
|
2198
2226
|
// The classic parser read a name reference first when `@see` starts with an
|
|
2199
2227
|
// identifier; otherwise the text came back as [text(''), space, text], i.e.
|