Skip to content

Commit d1be956

Browse files
committedMay 2, 2024
Allow functions to have comments
Resolves: #2521
1 parent e30ed7a commit d1be956

File tree

15 files changed

+197
-194
lines changed

15 files changed

+197
-194
lines changed
 

‎.github/ISSUE_TEMPLATE/bug_report.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ labels: bug
2222
Note: Turn off skipErrorChecks before reporting a crash. Bug reports for crashes with that option
2323
on are out of scope.
2424
25-
If possible, please create a *minimal* repo reproducing your problem and link it.
26-
You can easily do this by submitting a pull request to https://github.com/TypeStrong/typedoc-repros
25+
If possible, please create a *minimal* repo reproducing your problem.
26+
If it is more than a single small file, please submit a pull request to
27+
https://github.com/TypeStrong/typedoc-repros
2728
which changes the files necessary to reproduce your bug.
2829
2930
If this is not possible, include at least:

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Beta
22

3+
Docs needing updating:
4+
@license, @import
5+
sitemapBaseUrl
6+
markedOptions -> markdownItOptions, markdownItLoader, navigation
7+
38
## Breaking Changes
49

510
- Drop support for Node 16.
@@ -9,6 +14,11 @@
914
- Updated Shiki from 0.14 to 1.3. This should mostly be a transparent update which adds another 23 supported languages and 13 supported themes.
1015
- Renamed `--sitemapBaseUrl` to `--hostedBaseUrl` to reflect that it can be used for more than just the sitemap.
1116
- Removed deprecated `navigation.fullTree` option.
17+
- All function-likes may now have comments directly attached to them. This is a change from previous versions of TypeDoc where functions comments
18+
were always moved down to the signature level. This mostly worked, but caused problems with type aliases, so was partially changed in 0.25.13.
19+
This change was extended to apply not only to type aliases, but also other function-likes declared with variables and callable properties.
20+
As a part of this change, comments on the implementation signature of overloaded functions will now be added to the function reflection, and will
21+
not be inherited by signatures of that function, #2521.
1222
- API: `MapOptionDeclaration.mapError` has been removed.
1323
- API: Deprecated `BindOption` decorator has been removed.
1424
- API: `DeclarationReflection.indexSignature` has been renamed to `DeclarationReflection.indexSignatures`.

‎src/lib/converter/comments/discovery.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,22 @@ export function discoverComment(
178178
}
179179
seen.add(node);
180180

181-
// Special behavior here! We temporarily put the implementation comment
182-
// on the reflection which contains all the signatures. This lets us pull
183-
// the comment on the implementation if some signature does not have a comment.
184-
// However, we don't want to skip the node if it is a reference to something.
185-
// See the gh1770 test for an example.
181+
// Special behavior here!
182+
// Signatures and symbols have two distinct discovery methods as of TypeDoc 0.26.
183+
// This method discovers comments for symbols, and function-likes will only have
184+
// a symbol comment if there is more than one signature (== more than one declaration)
185+
// and there is a comment on the implementation signature.
186186
if (
187187
kind & ReflectionKind.ContainsCallSignatures &&
188188
[
189189
ts.SyntaxKind.FunctionDeclaration,
190190
ts.SyntaxKind.MethodDeclaration,
191191
ts.SyntaxKind.Constructor,
192192
].includes(node.kind) &&
193-
!(node as ts.FunctionDeclaration).body
193+
(symbol.declarations!.filter((d) =>
194+
wantedKinds[kind].includes(d.kind),
195+
).length === 1 ||
196+
!(node as ts.FunctionDeclaration).body)
194197
) {
195198
continue;
196199
}

‎src/lib/converter/plugins/CommentPlugin.ts‎

Lines changed: 59 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import {
1010
SignatureReflection,
1111
type ParameterReflection,
1212
Comment,
13-
ReflectionType,
1413
type SourceReference,
1514
type TypeVisitor,
1615
CommentTag,
16+
ReflectionType,
1717
} from "../../models";
1818
import {
1919
Option,
@@ -359,123 +359,78 @@ export class CommentPlugin extends ConverterComponent {
359359
movePropertyTags(reflection.comment, reflection);
360360
}
361361

362-
if (!(reflection instanceof DeclarationReflection)) {
363-
return;
362+
if (reflection instanceof DeclarationReflection && reflection.comment) {
363+
let sigs: SignatureReflection[];
364+
if (reflection.type instanceof ReflectionType) {
365+
sigs = reflection.type.declaration.getNonIndexSignatures();
366+
} else {
367+
sigs = reflection.getNonIndexSignatures();
368+
}
369+
370+
// For variables and properties, the symbol might own the comment but we might also
371+
// have @param and @returns comments for an owned signature. Only do this if there is
372+
// exactly one signature as otherwise we have no hope of doing validation right.
373+
if (sigs.length === 1 && !sigs[0].comment) {
374+
this.moveSignatureParamComments(sigs[0], reflection.comment);
375+
const returnsTag = reflection.comment.getTag("@returns");
376+
if (returnsTag) {
377+
sigs[0].comment = new Comment();
378+
sigs[0].comment.blockTags.push(returnsTag);
379+
reflection.comment.removeTags("@returns");
380+
}
381+
}
364382
}
365383

366-
if (reflection.type instanceof ReflectionType) {
367-
this.moveCommentToSignatures(
368-
reflection,
369-
reflection.type.declaration.getNonIndexSignatures(),
370-
);
371-
} else {
372-
this.moveCommentToSignatures(
373-
reflection,
374-
reflection.getNonIndexSignatures(),
375-
);
384+
if (reflection instanceof SignatureReflection) {
385+
this.moveSignatureParamComments(reflection);
376386
}
377387
}
378388

379-
private moveCommentToSignatures(
380-
reflection: DeclarationReflection,
381-
signatures: SignatureReflection[],
389+
private moveSignatureParamComments(
390+
signature: SignatureReflection,
391+
comment = signature.comment,
382392
) {
383-
if (!signatures.length) {
384-
return;
385-
}
386-
387-
const comment = reflection.kindOf(ReflectionKind.ClassOrInterface)
388-
? undefined
389-
: reflection.comment;
390-
391-
for (const signature of signatures) {
392-
const signatureHadOwnComment = !!signature.comment;
393-
const childComment = (signature.comment ||= comment?.clone());
394-
if (!childComment) continue;
395-
396-
signature.parameters?.forEach((parameter, index) => {
397-
if (parameter.name === "__namedParameters") {
398-
const commentParams = childComment.blockTags.filter(
399-
(tag) =>
400-
tag.tag === "@param" && !tag.name?.includes("."),
401-
);
402-
if (
403-
signature.parameters?.length === commentParams.length &&
404-
commentParams[index].name
405-
) {
406-
parameter.name = commentParams[index].name!;
407-
}
408-
}
393+
if (!comment) return;
409394

410-
const tag = childComment.getIdentifiedTag(
411-
parameter.name,
412-
"@param",
395+
signature.parameters?.forEach((parameter, index) => {
396+
if (parameter.name === "__namedParameters") {
397+
const commentParams = comment.blockTags.filter(
398+
(tag) => tag.tag === "@param" && !tag.name?.includes("."),
413399
);
414-
415-
if (tag) {
416-
parameter.comment = new Comment(
417-
Comment.cloneDisplayParts(tag.content),
418-
);
419-
}
420-
});
421-
422-
for (const parameter of signature.typeParameters || []) {
423-
const tag =
424-
childComment.getIdentifiedTag(
425-
parameter.name,
426-
"@typeParam",
427-
) ||
428-
childComment.getIdentifiedTag(
429-
parameter.name,
430-
"@template",
431-
) ||
432-
childComment.getIdentifiedTag(
433-
`<${parameter.name}>`,
434-
"@param",
435-
);
436-
if (tag) {
437-
parameter.comment = new Comment(
438-
Comment.cloneDisplayParts(tag.content),
439-
);
400+
if (
401+
signature.parameters?.length === commentParams.length &&
402+
commentParams[index].name
403+
) {
404+
parameter.name = commentParams[index].name!;
440405
}
441406
}
442407

443-
this.validateParamTags(
444-
signature,
445-
childComment,
446-
signature.parameters || [],
447-
signatureHadOwnComment,
448-
);
408+
const tag = comment.getIdentifiedTag(parameter.name, "@param");
449409

450-
childComment?.removeTags("@param");
451-
childComment?.removeTags("@typeParam");
452-
childComment?.removeTags("@template");
453-
}
410+
if (tag) {
411+
parameter.comment = new Comment(
412+
Comment.cloneDisplayParts(tag.content),
413+
);
414+
}
415+
});
454416

455-
// Since this reflection has signatures, we need to remove the comment from the non-primary
456-
// declaration location. For functions/methods/constructors, this means removing it from
457-
// the wrapping reflection. For type aliases, classes, and interfaces, this means removing
458-
// it from the contained signatures... if it's the same as what is on the signature.
459-
// This is important so that in type aliases we don't end up with a comment rendered twice.
460-
if (reflection.kindOf(ReflectionKind.SignatureContainer)) {
461-
delete reflection.comment;
462-
} else {
463-
reflection.comment?.removeTags("@param");
464-
reflection.comment?.removeTags("@typeParam");
465-
reflection.comment?.removeTags("@template");
466-
467-
const parentComment = Comment.combineDisplayParts(
468-
reflection.comment?.summary,
469-
);
470-
for (const sig of signatures) {
471-
if (
472-
Comment.combineDisplayParts(sig.comment?.summary) ===
473-
parentComment
474-
) {
475-
delete sig.comment;
476-
}
417+
for (const parameter of signature.typeParameters || []) {
418+
const tag =
419+
comment.getIdentifiedTag(parameter.name, "@typeParam") ||
420+
comment.getIdentifiedTag(parameter.name, "@template") ||
421+
comment.getIdentifiedTag(`<${parameter.name}>`, "@param");
422+
if (tag) {
423+
parameter.comment = new Comment(
424+
Comment.cloneDisplayParts(tag.content),
425+
);
477426
}
478427
}
428+
429+
this.validateParamTags(signature, comment, signature.parameters || []);
430+
431+
comment.removeTags("@param");
432+
comment.removeTags("@typeParam");
433+
comment.removeTags("@template");
479434
}
480435

481436
private removeExcludedTags(comment: Comment) {
@@ -607,7 +562,6 @@ export class CommentPlugin extends ConverterComponent {
607562
signature: SignatureReflection,
608563
comment: Comment,
609564
params: ParameterReflection[],
610-
signatureHadOwnComment: boolean,
611565
) {
612566
const paramTags = comment.blockTags.filter(
613567
(tag) => tag.tag === "@param",
@@ -619,7 +573,7 @@ export class CommentPlugin extends ConverterComponent {
619573

620574
moveNestedParamTags(/* in-out */ paramTags, params);
621575

622-
if (signatureHadOwnComment && paramTags.length) {
576+
if (paramTags.length) {
623577
for (const tag of paramTags) {
624578
this.application.logger.warn(
625579
this.application.i18n.signature_0_has_unused_param_with_name_1(

‎src/lib/converter/symbols.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,6 @@ function convertFunctionOrMethod(
486486

487487
const scope = context.withScope(reflection);
488488

489-
// Can't use zip here. We might have less declarations than signatures
490-
// or less signatures than declarations.
491489
for (const sig of signatures) {
492490
createSignature(scope, ReflectionKind.CallSignature, sig, symbol);
493491
}

‎src/lib/models/reflections/abstract.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,10 @@ export abstract class Reflection {
329329
* Test whether this reflection is of the given kind.
330330
*/
331331
kindOf(kind: ReflectionKind | ReflectionKind[]): boolean {
332-
const kindArray = Array.isArray(kind) ? kind : [kind];
333-
return kindArray.some((kind) => (this.kind & kind) !== 0);
332+
const kindFlags = Array.isArray(kind)
333+
? kind.reduce((a, b) => a | b, 0)
334+
: kind;
335+
return (this.kind & kindFlags) !== 0;
334336
}
335337

336338
/**

‎src/lib/utils/options/sources/typedoc.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
318318
help: (i18n) => i18n.help_markdownItOptions(),
319319
type: ParameterType.Mixed,
320320
configFileOnly: true,
321-
defaultValue: {},
321+
defaultValue: {
322+
linkify: true,
323+
},
322324
validate(value, i18n) {
323325
if (!Validation.validate({}, value)) {
324326
throw new Error(

‎src/lib/validation/documentation.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function validateDocumentation(
4343
if (seen.has(ref)) continue;
4444
seen.add(ref);
4545

46-
// If we're a non-parameter inside a parameter, we shouldn't care. Parameters don't get deeply documented
46+
// If inside a parameter, we shouldn't care. Callback parameter's values don't get deeply documented.
4747
let r: Reflection | undefined = ref.parent;
4848
while (r) {
4949
if (r.kindOf(ReflectionKind.Parameter)) {
@@ -71,7 +71,7 @@ export function validateDocumentation(
7171
continue;
7272
}
7373

74-
// Call signatures are considered documented if they are directly within a documented type alias.
74+
// Construct signatures are considered documented if they are directly within a documented type alias.
7575
if (
7676
ref.kindOf(ReflectionKind.ConstructorSignature) &&
7777
ref.parent?.parent?.kindOf(ReflectionKind.TypeAlias)

‎src/test/behavior.c2.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,11 @@ describe("Behavior Tests", () => {
957957
const barComments = bar.signatures?.map((sig) =>
958958
Comment.combineDisplayParts(sig.comment?.summary),
959959
);
960-
equal(barComments, ["Implementation comment", "Custom comment"]);
961-
equal(bar.comment, undefined);
960+
equal(barComments, ["", "Custom comment"]);
961+
equal(
962+
Comment.combineDisplayParts(bar.comment?.summary),
963+
"Implementation comment",
964+
);
962965

963966
logger.expectMessage(
964967
'warn: The label "bad" for badLabel cannot be referenced with a declaration reference. Labels may only contain A-Z, 0-9, and _, and may not start with a number.',

‎src/test/converter/function/function.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ export function multipleSignatures(value: string): string;
9595
export function multipleSignatures(value: { name: string }): string;
9696

9797
/**
98-
* This is the actual implementation, this comment will not be visible
99-
* in the generated documentation. The `@inheritdoc` tag can not be used
100-
* to pull content from this signature into documentation for the real
101-
* signatures.
102-
*
103-
* @return This is the return value of the function.
98+
* This comment is on the actual implementation of the function.
99+
* TypeDoc used to allow this for providing "default" comments that would be
100+
* copied to each signature. It no longer does this, and instead treats
101+
* this comment as belonging to the function reflection itself.
102+
* Any `@param` or `@returns` tags within this comment won't be applied
103+
* to signatures.
104104
*/
105105
export function multipleSignatures(): string {
106106
if (arguments.length > 0) {

‎src/test/converter/function/specs.json‎

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,14 @@
425425
"variant": "declaration",
426426
"kind": 64,
427427
"flags": {},
428+
"comment": {
429+
"summary": [
430+
{
431+
"kind": "text",
432+
"text": "Returns true if fn returns true for every item in the iterator\n\nReturns true if the iterator is empty"
433+
}
434+
]
435+
},
428436
"sources": [
429437
{
430438
"fileName": "function.ts",
@@ -440,14 +448,6 @@
440448
"variant": "signature",
441449
"kind": 4096,
442450
"flags": {},
443-
"comment": {
444-
"summary": [
445-
{
446-
"kind": "text",
447-
"text": "Returns true if fn returns true for every item in the iterator\n\nReturns true if the iterator is empty"
448-
}
449-
]
450-
},
451451
"sources": [
452452
{
453453
"fileName": "function.ts",
@@ -565,14 +565,6 @@
565565
"variant": "signature",
566566
"kind": 4096,
567567
"flags": {},
568-
"comment": {
569-
"summary": [
570-
{
571-
"kind": "text",
572-
"text": "Returns true if fn returns true for every item in the iterator\n\nReturns true if the iterator is empty"
573-
}
574-
]
575-
},
576568
"sources": [
577569
{
578570
"fileName": "function.ts",
@@ -1745,6 +1737,30 @@
17451737
"variant": "declaration",
17461738
"kind": 64,
17471739
"flags": {},
1740+
"comment": {
1741+
"summary": [
1742+
{
1743+
"kind": "text",
1744+
"text": "This comment is on the actual implementation of the function.\nTypeDoc used to allow this for providing \"default\" comments that would be\ncopied to each signature. It no longer does this, and instead treats\nthis comment as belonging to the function reflection itself.\nAny "
1745+
},
1746+
{
1747+
"kind": "code",
1748+
"text": "`@param`"
1749+
},
1750+
{
1751+
"kind": "text",
1752+
"text": " or "
1753+
},
1754+
{
1755+
"kind": "code",
1756+
"text": "`@returns`"
1757+
},
1758+
{
1759+
"kind": "text",
1760+
"text": " tags within this comment won't be applied\nto signatures."
1761+
}
1762+
]
1763+
},
17481764
"sources": [
17491765
{
17501766
"fileName": "function.ts",
@@ -1921,6 +1937,14 @@
19211937
"variant": "declaration",
19221938
"kind": 64,
19231939
"flags": {},
1940+
"comment": {
1941+
"summary": [
1942+
{
1943+
"kind": "text",
1944+
"text": "This is a function that is assigned to a variable."
1945+
}
1946+
]
1947+
},
19241948
"sources": [
19251949
{
19261950
"fileName": "function.ts",
@@ -1937,12 +1961,7 @@
19371961
"kind": 4096,
19381962
"flags": {},
19391963
"comment": {
1940-
"summary": [
1941-
{
1942-
"kind": "text",
1943-
"text": "This is a function that is assigned to a variable."
1944-
}
1945-
],
1964+
"summary": [],
19461965
"blockTags": [
19471966
{
19481967
"tag": "@returns",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @typedef {string} Foo */
22

3-
/** @param {Foo} x */
3+
/** @param {Foo} x x desc */
44
const foo = (x) => x;
55

66
module.exports = foo;

‎src/test/converter/js/specs.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@
6767
"variant": "param",
6868
"kind": 32768,
6969
"flags": {},
70+
"comment": {
71+
"summary": [
72+
{
73+
"kind": "text",
74+
"text": "x desc"
75+
}
76+
]
77+
},
7078
"type": {
7179
"type": "intrinsic",
7280
"name": "string"

‎src/test/converter/mixin/specs.json‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,14 @@
15321532
"variant": "declaration",
15331533
"kind": 64,
15341534
"flags": {},
1535+
"comment": {
1536+
"summary": [
1537+
{
1538+
"kind": "text",
1539+
"text": "The \"mixin function\" of the Mixin1"
1540+
}
1541+
]
1542+
},
15351543
"sources": [
15361544
{
15371545
"fileName": "mixin.ts",
@@ -1547,14 +1555,6 @@
15471555
"variant": "signature",
15481556
"kind": 4096,
15491557
"flags": {},
1550-
"comment": {
1551-
"summary": [
1552-
{
1553-
"kind": "text",
1554-
"text": "The \"mixin function\" of the Mixin1"
1555-
}
1556-
]
1557-
},
15581558
"sources": [
15591559
{
15601560
"fileName": "mixin.ts",
@@ -1720,6 +1720,14 @@
17201720
"variant": "declaration",
17211721
"kind": 64,
17221722
"flags": {},
1723+
"comment": {
1724+
"summary": [
1725+
{
1726+
"kind": "text",
1727+
"text": "The \"mixin function\" of the Mixin2"
1728+
}
1729+
]
1730+
},
17231731
"sources": [
17241732
{
17251733
"fileName": "mixin.ts",
@@ -1735,14 +1743,6 @@
17351743
"variant": "signature",
17361744
"kind": 4096,
17371745
"flags": {},
1738-
"comment": {
1739-
"summary": [
1740-
{
1741-
"kind": "text",
1742-
"text": "The \"mixin function\" of the Mixin2"
1743-
}
1744-
]
1745-
},
17461746
"sources": [
17471747
{
17481748
"fileName": "mixin.ts",
@@ -1919,6 +1919,14 @@
19191919
"variant": "declaration",
19201920
"kind": 64,
19211921
"flags": {},
1922+
"comment": {
1923+
"summary": [
1924+
{
1925+
"kind": "text",
1926+
"text": "The \"mixin function\" of the Mixin3"
1927+
}
1928+
]
1929+
},
19221930
"sources": [
19231931
{
19241932
"fileName": "mixin.ts",
@@ -1940,14 +1948,6 @@
19401948
"variant": "signature",
19411949
"kind": 4096,
19421950
"flags": {},
1943-
"comment": {
1944-
"summary": [
1945-
{
1946-
"kind": "text",
1947-
"text": "The \"mixin function\" of the Mixin3"
1948-
}
1949-
]
1950-
},
19511951
"sources": [
19521952
{
19531953
"fileName": "mixin.ts",

‎src/test/issues.c2.test.ts‎

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,13 @@ describe("Issue Tests", () => {
406406
);
407407

408408
const comments = [
409-
project.children[0].comment?.summary,
410-
project.children[0].children[0].comment?.summary,
411-
project.children[0].children[1].signatures![0].comment?.summary,
412-
project.children[0].signatures![0].comment?.summary,
413-
].map(Comment.combineDisplayParts);
409+
query(project, "bar"),
410+
query(project, "bar.metadata"),
411+
querySig(project, "bar.fn"),
412+
querySig(project, "bar"),
413+
].map((r) => Comment.combineDisplayParts(r.comment?.summary));
414414

415-
equal(comments, ["", "metadata", "fn", "bar"]);
415+
equal(comments, ["bar", "metadata", "fn", ""]);
416416
});
417417

418418
it("#1660", () => {
@@ -475,7 +475,7 @@ describe("Issue Tests", () => {
475475
const project = convert();
476476
const sym1 = query(project, "sym1");
477477
equal(
478-
Comment.combineDisplayParts(sym1.signatures?.[0].comment?.summary),
478+
Comment.combineDisplayParts(sym1.comment?.summary),
479479
"Docs for Sym1",
480480
);
481481

@@ -717,9 +717,7 @@ describe("Issue Tests", () => {
717717
equal(comments, ["A override", "B module"]);
718718

719719
const comments2 = ["A.a", "B.b"].map((n) =>
720-
Comment.combineDisplayParts(
721-
query(project, n).signatures![0].comment?.summary,
722-
),
720+
Comment.combineDisplayParts(query(project, n).comment?.summary),
723721
);
724722

725723
equal(comments2, ["Comment for a", "Comment for b"]);
@@ -792,7 +790,7 @@ describe("Issue Tests", () => {
792790

793791
it("#2008", () => {
794792
const project = convert();
795-
const fn = query(project, "myFn").signatures![0];
793+
const fn = query(project, "myFn");
796794
equal(Comment.combineDisplayParts(fn.comment?.summary), "Docs");
797795
});
798796

@@ -891,20 +889,25 @@ describe("Issue Tests", () => {
891889

892890
it("#2042", () => {
893891
const project = convert();
894-
for (const [name, docs] of [
895-
["built", "inner docs"],
896-
["built2", "outer docs"],
897-
["fn", "inner docs"],
898-
["fn2", "outer docs"],
892+
for (const [name, docs, sigDocs] of [
893+
["built", "", "inner docs"],
894+
["built2", "outer docs", ""],
895+
["fn", "", "inner docs"],
896+
["fn2", "outer docs", ""],
899897
]) {
900898
const refl = query(project, name);
901899
ok(refl.signatures?.[0]);
900+
equal(
901+
Comment.combineDisplayParts(refl.comment?.summary),
902+
docs,
903+
name + " docs",
904+
);
902905
equal(
903906
Comment.combineDisplayParts(
904907
refl.signatures[0].comment?.summary,
905908
),
906-
docs,
907-
name,
909+
sigDocs,
910+
name + " sig docs",
908911
);
909912
}
910913
});
@@ -1009,7 +1012,7 @@ describe("Issue Tests", () => {
10091012
const foo = query(project, "foo");
10101013
equal(foo.signatures?.length, 1);
10111014
equal(
1012-
Comment.combineDisplayParts(foo.signatures[0].comment?.summary),
1015+
Comment.combineDisplayParts(foo.comment?.summary),
10131016
"Is documented",
10141017
);
10151018
});

0 commit comments

Comments
 (0)
Please sign in to comment.