File tree 4 files changed +54
-3
lines changed 4 files changed +54
-3
lines changed Original file line number Diff line number Diff line change 5
5
- Added a new ` --sitemapBaseUrl ` option. When specified, TypeDoc will generate a ` sitemap.xml ` in your output folder that describes the site, #2480 .
6
6
- Added support for the ` @class ` tag. When added to a comment on a variable or function, TypeDoc will convert the member as a class, #2479 .
7
7
Note: This should only be used on symbols which actually represent a class, but are not declared as a class for some reason.
8
-
9
- ## Features
10
-
11
8
- Added support for ` @groupDescription ` and ` @categoryDescription ` to provide a description of groups and categories, #2494 .
9
+ - Exposed ` Context.getNodeComment ` for plugin use, #2498 .
12
10
13
11
## Bug Fixes
14
12
Original file line number Diff line number Diff line change @@ -133,6 +133,29 @@ export function discoverFileComment(
133
133
}
134
134
}
135
135
136
+ export function discoverNodeComment (
137
+ node : ts . Node ,
138
+ commentStyle : CommentStyle ,
139
+ ) : DiscoveredComment | undefined {
140
+ const text = node . getSourceFile ( ) . text ;
141
+ const comments = collectCommentRanges (
142
+ ts . getLeadingCommentRanges ( text , node . pos ) ,
143
+ ) ;
144
+ comments . reverse ( ) ;
145
+
146
+ const selectedDocComment = comments . find ( ( ranges ) =>
147
+ permittedRange ( text , ranges , commentStyle ) ,
148
+ ) ;
149
+
150
+ if ( selectedDocComment ) {
151
+ return {
152
+ file : node . getSourceFile ( ) ,
153
+ ranges : selectedDocComment ,
154
+ jsDoc : findJsDocForComment ( node , selectedDocComment ) ,
155
+ } ;
156
+ }
157
+ }
158
+
136
159
export function discoverComment (
137
160
symbol : ts . Symbol ,
138
161
kind : ReflectionKind ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
10
10
DiscoveredComment ,
11
11
discoverComment ,
12
12
discoverFileComment ,
13
+ discoverNodeComment ,
13
14
discoverSignatureComment ,
14
15
} from "./discovery" ;
15
16
import { lexLineComments } from "./lineLexer" ;
@@ -171,6 +172,23 @@ export function getComment(
171
172
return comment ;
172
173
}
173
174
175
+ export function getNodeComment (
176
+ node : ts . Node ,
177
+ kind : ReflectionKind ,
178
+ config : CommentParserConfig ,
179
+ logger : Logger ,
180
+ commentStyle : CommentStyle ,
181
+ checker : ts . TypeChecker | undefined ,
182
+ ) {
183
+ return getCommentImpl (
184
+ discoverNodeComment ( node , commentStyle ) ,
185
+ config ,
186
+ logger ,
187
+ kind === ReflectionKind . Module ,
188
+ checker ,
189
+ ) ;
190
+ }
191
+
174
192
export function getFileComment (
175
193
file : ts . SourceFile ,
176
194
config : CommentParserConfig ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
18
18
getComment ,
19
19
getFileComment ,
20
20
getJsDocComment ,
21
+ getNodeComment ,
21
22
getSignatureComment ,
22
23
} from "./comments" ;
23
24
import { getHumanName } from "../utils/tsutils" ;
@@ -270,6 +271,17 @@ export class Context {
270
271
) ;
271
272
}
272
273
274
+ getNodeComment ( node : ts . Node , kind : ReflectionKind ) {
275
+ return getNodeComment (
276
+ node ,
277
+ kind ,
278
+ this . converter . config ,
279
+ this . logger ,
280
+ this . converter . commentStyle ,
281
+ this . converter . useTsLinkResolution ? this . checker : undefined ,
282
+ ) ;
283
+ }
284
+
273
285
getFileComment ( node : ts . SourceFile ) {
274
286
return getFileComment (
275
287
node ,
You can’t perform that action at this time.
0 commit comments