Skip to content

Commit

Permalink
fix(core): expose comment for arrow functions in type declarations (#670
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tgreyuk committed Aug 15, 2024
1 parent 099ef16 commit 7afe341
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-lions-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'typedoc-plugin-markdown': patch
---

- Expose comment for arrow functions in type declarations (#670)
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ export function declaration(
const typeDeclaration = (model.type as any)
?.declaration as DeclarationReflection;

const showComments = !typeDeclaration?.signatures?.every((signature) =>
Boolean(signature.comment),
);

if (showComments && model.comment) {
if (model.comment) {
md.push(
this.partials.comment(model.comment, {
headingLevel: opts.headingLevel,
Expand Down Expand Up @@ -161,7 +157,7 @@ export function declaration(
}
}

if (showComments && model.comment) {
if (model.comment) {
md.push(
this.partials.comment(model.comment, {
headingLevel: opts.headingLevel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export type LiteralType = {
* @param param
*/
someFunction(param: string): Promise<any>;
/**
* Comments for someFunctionWithArrow
*/
someFunctionWithArrow: () => string;
/**
* Comments for accessorA getter
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,22 @@ bar: number;
exports[`Objects And Params should compile literal type: (Output File Strategy "members") (Option Group "1") 1`] = `
"# Type Alias: LiteralType
> **LiteralType**: \\{\`x\`: \`string\`;\`y\`: \\{\`x\`: \`string\`;\`y\`: \`boolean\` \\| \`string\`;\`z\`: (\`x\`: \`string\`) => \`string\`; \\};\`z\`: (\`x\`: \`string\`) => \`string\`;get set \`accessorA\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>;get set \`accessorB\`: \`string\`;\`someFunction\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\>; \\}
> **LiteralType**: \\{\`someFunctionWithArrow\`: () => \`string\`;\`x\`: \`string\`;\`y\`: \\{\`x\`: \`string\`;\`y\`: \`boolean\` \\| \`string\`;\`z\`: (\`x\`: \`string\`) => \`string\`; \\};\`z\`: (\`x\`: \`string\`) => \`string\`;get set \`accessorA\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>;get set \`accessorB\`: \`string\`;\`someFunction\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\>; \\}
Comments for LiteralType
## Type declaration
### someFunctionWithArrow()
> **someFunctionWithArrow**: () => \`string\`
Comments for someFunctionWithArrow
#### Returns
\`string\`
### x
> **x**: \`string\`
Expand Down Expand Up @@ -595,6 +605,7 @@ exports[`Objects And Params should compile literal type: (Output File Strategy "
\`\`\`ts
type LiteralType: {
someFunctionWithArrow: () => string;
x: string;
y: {
x: string;
Expand All @@ -612,6 +623,18 @@ Comments for LiteralType
## Type declaration
### someFunctionWithArrow()
\`\`\`ts
someFunctionWithArrow: () => string;
\`\`\`
Comments for someFunctionWithArrow
#### Returns
\`string\`
### x
\`\`\`ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ Comments for LiteralType
## Type declaration
### someFunctionWithArrow()
> **someFunctionWithArrow**: () => \`string\`
Comments for someFunctionWithArrow
#### Returns
\`string\`
### x
> **x**: \`string\`
Expand Down Expand Up @@ -216,6 +226,7 @@ Comments for LiteralType
| Name | Type | Description |
| :------ | :------ | :------ |
| \`someFunctionWithArrow\` | () => \`string\` | Comments for someFunctionWithArrow |
| \`x\` | \`string\` | comment for x |
| \`y\` | \`object\` | comment for y |
| \`y.x\` | \`string\` | comment for y.x |
Expand Down

0 comments on commit 7afe341

Please sign in to comment.