Skip to content

Commit c66f769

Browse files
committed
fix(frontmatter): correctly resolve frontmatterCommentTags for signatures
1 parent 7a27fbf commit c66f769

14 files changed

+239
-8
lines changed

.changeset/config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"updateInternalDependencies": "minor",
1313
"ignore": [
1414
"@devtools/*",
15-
"typedoc-plugin-frontmatter",
1615
"typedoc-github-wiki-theme",
1716
"typedoc-gitlab-wiki-theme",
1817
"typedoc-vitepress-theme",

.changeset/lazy-bats-stay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'typedoc-plugin-frontmatter': patch
3+
---
4+
5+
- Correctly resolve `frontmatterCommentTags` for signatures (#848).

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/typedoc-plugin-frontmatter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"homepage": "https://typedoc-plugin-markdown.org/plugins/frontmatter",
3333
"dependencies": {
34-
"yaml": "^2.7.0"
34+
"yaml": "^2.8.1"
3535
},
3636
"peerDependencies": {
3737
"typedoc-plugin-markdown": ">=4.9.0"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Functionality to map models to comments.
3+
*
4+
* @module
5+
*/
6+
import { Comment, DeclarationReflection, ReflectionKind } from 'typedoc';
7+
8+
export function getComment(model: DeclarationReflection): Comment | undefined {
9+
if (
10+
model.kind === ReflectionKind.Function &&
11+
model.signatures?.length === 1
12+
) {
13+
return model.signatures[0].comment;
14+
}
15+
16+
return model.comment;
17+
}

packages/typedoc-plugin-frontmatter/src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
MarkdownPageEvent,
1515
} from 'typedoc-plugin-markdown';
1616
import * as yaml from 'yaml';
17+
import { getComment } from './comments.js';
1718
import { declarations } from './options/index.js';
1819
import { getResolvedTags } from './tags.js';
1920

@@ -28,14 +29,12 @@ export function load(app: MarkdownApplication) {
2829
app.renderer.on(
2930
MarkdownPageEvent.BEGIN,
3031
(page: MarkdownPageEvent<DeclarationReflection>) => {
31-
const entryFileName = app.options.getValue('entryFileName') as any;
32+
const entryFileName = app.options.getValue('entryFileName') as string;
3233
const frontmatterGlobals = app.options.getValue('frontmatterGlobals');
3334
const readmeFrontmatter = app.options.getValue('readmeFrontmatter');
3435
const indexFrontmatter = app.options.getValue('indexFrontmatter');
35-
const resolvedFrontmatterTags = getResolvedTags(
36-
app,
37-
(page.model as DeclarationReflection)?.comment,
38-
);
36+
const comment = getComment(page.model);
37+
const resolvedFrontmatterTags = getResolvedTags(app, comment);
3938

4039
page.frontmatter = {
4140
...(page.frontmatter || {}),
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: someFunction
3+
layout: blog
4+
navOrder: 1
5+
hide: true
6+
tagOne: Tag value
7+
---
8+
9+
# Function: someFunction()
10+
11+
> **someFunction**(): `void`
12+
13+
## Returns
14+
15+
`void`
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: someFunctionWithMultipleSignatures
3+
layout: blog
4+
navOrder: 1
5+
hide: true
6+
tagOne: Tag value
7+
---
8+
9+
# Function: someFunctionWithMultipleSignatures()
10+
11+
Comments for greet function
12+
13+
## Call Signature
14+
15+
> **someFunctionWithMultipleSignatures**(`name`): `string`
16+
17+
Comments for overload function A
18+
19+
### Parameters
20+
21+
#### name
22+
23+
`string`
24+
25+
### Returns
26+
27+
`string`
28+
29+
## Call Signature
30+
31+
> **someFunctionWithMultipleSignatures**(`firstName`, `lastName`): `string`
32+
33+
Comments for overload function B
34+
35+
### Parameters
36+
37+
#### firstName
38+
39+
`string`
40+
41+
#### lastName
42+
43+
`string`
44+
45+
### Returns
46+
47+
`string`
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: someFunctionWithMultipleSignatures
3+
layout: blog
4+
veryLong: This is a long string that would normally wrap over multiple lines when the text exceeds a certain length.
5+
navOrder: 1
6+
hide: true
7+
tagOne: Tag value
8+
---
9+
10+
# Function: someFunctionWithMultipleSignatures()
11+
12+
Comments for greet function
13+
14+
## Tag One
15+
16+
Tag value
17+
18+
## Call Signature
19+
20+
> **someFunctionWithMultipleSignatures**(`name`): `string`
21+
22+
Comments for overload function A
23+
24+
### Parameters
25+
26+
#### name
27+
28+
`string`
29+
30+
### Returns
31+
32+
`string`
33+
34+
## Call Signature
35+
36+
> **someFunctionWithMultipleSignatures**(`firstName`, `lastName`): `string`
37+
38+
Comments for overload function B
39+
40+
### Parameters
41+
42+
#### firstName
43+
44+
`string`
45+
46+
#### lastName
47+
48+
`string`
49+
50+
### Returns
51+
52+
`string`
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: someFunction
3+
layout: blog
4+
veryLong: This is a long string that would normally wrap over multiple lines when the text exceeds a certain length.
5+
navOrder: 1
6+
hide: true
7+
tagOne: Tag value
8+
---
9+
10+
# Function: someFunction()
11+
12+
> **someFunction**(): `void`
13+
14+
## Returns
15+
16+
`void`
17+
18+
## Tag One
19+
20+
Tag value

0 commit comments

Comments
 (0)