Skip to content

Commit ffac19c

Browse files
committed
fix(core): fix incorrect overload function comments (#827)
1 parent 8bc50c8 commit ffac19c

File tree

6 files changed

+53
-27
lines changed

6 files changed

+53
-27
lines changed

.changeset/crazy-groups-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'typedoc-plugin-markdown': patch
3+
---
4+
5+
- Fix incorrect overload function comments (#827).

packages/typedoc-plugin-markdown/src/theme/context/partials/member.signature.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,10 @@ export function signature(
3131
md.push(this.partials.sources(model));
3232
}
3333

34-
let modelComments = options.multipleSignatures
34+
const modelComments = options.multipleSignatures
3535
? model.comment
3636
: model.comment || model.parent?.comment;
3737

38-
if (
39-
modelComments &&
40-
model.parent?.comment?.summary &&
41-
!options.multipleSignatures
42-
) {
43-
modelComments = Object.assign(modelComments, {
44-
summary: model.parent.comment.summary,
45-
});
46-
}
47-
48-
if (modelComments && model.parent?.comment?.blockTags) {
49-
modelComments.blockTags = [
50-
...(model.parent?.comment?.blockTags || []),
51-
...(model.comment?.blockTags || []),
52-
];
53-
}
54-
5538
if (modelComments) {
5639
md.push(
5740
this.partials.comment(modelComments, {

packages/typedoc-plugin-markdown/test/fixtures/src/reflections/interfaces.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,23 @@ export interface InterfaceWithSingleFunction {
249249
}
250250

251251
/**
252-
* Comments for InterfaceWithFunction
252+
* Comments for InterfaceWithFunctionOverloads
253+
*
254+
* @remarks parent block tag
253255
*
254256
* @inline
255257
*/
256258
export interface InterfaceWithFunctionOverloads {
257259
/**
258260
* Comments for function 1
261+
*
262+
* @remarks function1 block tag
259263
*/
260264
(options?: any): Promise<void>;
261265
/**
262266
* Comments for function 2
267+
*
268+
* @remarks function2 block tag
263269
*/
264270
(options2?: any): Promise<void>;
265271
}

packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,10 @@ Comments for function 1
519519
520520
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
521521
522+
##### Remarks
523+
524+
function1 block tag
525+
522526
#### Call Signature
523527
524528
> (\`options2?\`): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
@@ -535,6 +539,10 @@ Comments for function 2
535539
536540
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
537541
542+
##### Remarks
543+
544+
function2 block tag
545+
538546
### member3()
539547
540548
> **member3**: (\`options?\`) => [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
@@ -583,7 +591,7 @@ Return comments
583591
| \`member1()\` | \\{ (\`options?\`: \`any\`): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>; (\`signOutCallback?\`: \`any\`, \`options?\`: \`any\`): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>; \`prop1\`: \`string\`; \`prop2\`: \`string\`; \\} | Member 1 comments Comments for function 1 Comments for function 2 |
584592
| \`member1.prop1\` | \`string\` | Comments for prop 1 |
585593
| \`member1.prop2\` | \`string\` | Comments for prop 2 |
586-
| \`member2()\` | \\{ (\`options?\`: \`any\`): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>; (\`options2?\`: \`any\`): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>; \\} | Comments for function 1 Comments for function 2 |
594+
| \`member2()\` | \\{ (\`options?\`: \`any\`): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>; (\`options2?\`: \`any\`): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>; \\} | Comments for function 1 **Remarks** function1 block tag Comments for function 2 **Remarks** function2 block tag |
587595
| \`member3()\` | (\`options?\`: \`any\`) => [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\> | Member 3 comments Comments for function |
588596
| \`member4\` | \`object\` | - |
589597
| \`member4.prop\` | \`string\` | Comments for prop |

packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.index.spec.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Module comments
215215
| [InterfaceWithComments](interfaces/InterfaceWithComments.md) | Comments for interface over two lines |
216216
| [InterfaceWithEventProperties](interfaces/InterfaceWithEventProperties.md) | - |
217217
| [InterfaceWithFlags](interfaces/InterfaceWithFlags.md) | Comments for InterfaceWithFlags |
218-
| [InterfaceWithFunctionOverloads](interfaces/InterfaceWithFunctionOverloads.md) | Comments for InterfaceWithFunction |
218+
| [InterfaceWithFunctionOverloads](interfaces/InterfaceWithFunctionOverloads.md) | Comments for InterfaceWithFunctionOverloads |
219219
| [InterfaceWithMixedOverloads](interfaces/InterfaceWithMixedOverloads.md) | Comments for InterfaceWithFunctionOverloads |
220220
| [InterfaceWithProps](interfaces/InterfaceWithProps.md) | Comments for InterfaceWithFunction |
221221
| [InterfaceWithSingleFunction](interfaces/InterfaceWithSingleFunction.md) | Comments for InterfaceWithFunction |

packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.interface.spec.ts.snap

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -826,15 +826,19 @@ exports[`Interface Reflection should compile interface with function overloads:
826826
827827
Defined in: [interfaces.ts:1](http://source-url)
828828
829-
Comments for InterfaceWithFunction
829+
Comments for InterfaceWithFunctionOverloads
830+
831+
## Remarks
832+
833+
parent block tag
830834
831835
## Call Signature
832836
833837
> **InterfaceWithFunctionOverloads**(\`options?\`): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
834838
835839
Defined in: [interfaces.ts:1](http://source-url)
836840
837-
Comments for InterfaceWithFunction
841+
Comments for function 1
838842
839843
### Parameters
840844
@@ -846,13 +850,17 @@ Comments for InterfaceWithFunction
846850
847851
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
848852
853+
### Remarks
854+
855+
function1 block tag
856+
849857
## Call Signature
850858
851859
> **InterfaceWithFunctionOverloads**(\`options2?\`): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
852860
853861
Defined in: [interfaces.ts:1](http://source-url)
854862
855-
Comments for InterfaceWithFunction
863+
Comments for function 2
856864
857865
### Parameters
858866
@@ -863,6 +871,10 @@ Comments for InterfaceWithFunction
863871
### Returns
864872
865873
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
874+
875+
### Remarks
876+
877+
function2 block tag
866878
"
867879
`;
868880

@@ -871,7 +883,11 @@ exports[`Interface Reflection should compile interface with function overloads:
871883
872884
Defined in: [interfaces.ts:1](http://source-url)
873885
874-
Comments for InterfaceWithFunction
886+
Comments for InterfaceWithFunctionOverloads
887+
888+
## Remarks
889+
890+
parent block tag
875891
876892
## Call Signature
877893
@@ -881,7 +897,7 @@ InterfaceWithFunctionOverloads(options?: any): Promise<void>;
881897
882898
Defined in: [interfaces.ts:1](http://source-url)
883899
884-
Comments for InterfaceWithFunction
900+
Comments for function 1
885901
886902
### Parameters
887903
@@ -893,6 +909,10 @@ Comments for InterfaceWithFunction
893909
894910
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
895911
912+
### Remarks
913+
914+
function1 block tag
915+
896916
## Call Signature
897917
898918
\`\`\`ts
@@ -901,7 +921,7 @@ InterfaceWithFunctionOverloads(options2?: any): Promise<void>;
901921
902922
Defined in: [interfaces.ts:1](http://source-url)
903923
904-
Comments for InterfaceWithFunction
924+
Comments for function 2
905925
906926
### Parameters
907927
@@ -912,6 +932,10 @@ Comments for InterfaceWithFunction
912932
### Returns
913933
914934
[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`void\`\\>
935+
936+
### Remarks
937+
938+
function2 block tag
915939
"
916940
`;
917941

0 commit comments

Comments
 (0)