@@ -119,13 +119,26 @@ export function getRawComment(node: ts.Node): string | undefined {
119
119
} else {
120
120
node = getRootModuleDeclaration ( < ts . ModuleDeclaration > node ) ;
121
121
}
122
+ } else if ( node . kind === ts . SyntaxKind . NamespaceExport ) {
123
+ node = node . parent ;
124
+ } else if ( node . kind === ts . SyntaxKind . ExportSpecifier ) {
125
+ node = node . parent . parent ;
122
126
}
123
127
124
128
const sourceFile = node . getSourceFile ( ) ;
125
129
const comments = getJSDocCommentRanges ( node , sourceFile . text ) ;
126
130
if ( comments . length ) {
127
131
let comment : ts . CommentRange ;
128
- const explicitPackageComment = comments . find ( ( comment ) =>
132
+ let explicitPackageComment = comments . find ( ( comment ) =>
133
+ sourceFile . text
134
+ . substring ( comment . pos , comment . end )
135
+ . includes ( "@module" )
136
+ ) ;
137
+
138
+ // TODO: Deprecate and remove. This is an abuse of the @packageDocumentation tag. See:
139
+ // https://github.com/TypeStrong/typedoc/issues/1504#issuecomment-775842609
140
+ // Deprecate in 0.21, remove in 0.22
141
+ explicitPackageComment ??= comments . find ( ( comment ) =>
129
142
sourceFile . text
130
143
. substring ( comment . pos , comment . end )
131
144
. includes ( "@packageDocumentation" )
@@ -138,20 +151,33 @@ export function getRawComment(node: ts.Node): string | undefined {
138
151
// FUTURE: GH#1083, follow deprecation process to phase this out.
139
152
comment = comments [ 0 ] ;
140
153
} else {
141
- // Single comment that may be a license comment, bail.
154
+ // Single comment that may be a license comment, or no comments, bail.
142
155
return ;
143
156
}
144
157
} else {
145
158
comment = comments [ comments . length - 1 ] ;
146
159
// If a non-SourceFile node comment has this tag, it should not be attached to the node
147
160
// as it documents the whole file by convention.
161
+ // TODO: Deprecate and remove. This is an abuse of the @packageDocumentation tag. See:
162
+ // https://github.com/TypeStrong/typedoc/issues/1504#issuecomment-775842609
163
+ // Deprecate in 0.21, remove in 0.22
148
164
if (
149
165
sourceFile . text
150
166
. substring ( comment . pos , comment . end )
151
167
. includes ( "@packageDocumentation" )
152
168
) {
153
169
return ;
154
170
}
171
+
172
+ // If a non-SourceFile node comment has this tag, it should not be attached to the node
173
+ // as it documents the module.
174
+ if (
175
+ sourceFile . text
176
+ . substring ( comment . pos , comment . end )
177
+ . includes ( "@module" )
178
+ ) {
179
+ return ;
180
+ }
155
181
}
156
182
157
183
return sourceFile . text . substring ( comment . pos , comment . end ) ;
@@ -164,8 +190,8 @@ export function getRawComment(node: ts.Node): string | undefined {
164
190
* Parse the given doc comment string.
165
191
*
166
192
* @param text The doc comment string that should be parsed.
167
- * @param comment The [[Models. Comment]] instance the parsed results should be stored into.
168
- * @returns A populated [[Models. Comment]] instance.
193
+ * @param comment The { @link Comment} instance the parsed results should be stored into.
194
+ * @returns A populated { @link Comment} instance.
169
195
*/
170
196
export function parseComment (
171
197
text : string ,
0 commit comments