Skip to content

Commit 5e0f9a5

Browse files
committed
Completely ignore @see {@link ...} tag in parser
1 parent 403c9db commit 5e0f9a5

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/iterateJsdoc.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,31 @@ import getJSDocComment from './eslint/getJSDocComment';
1111
* @returns {object}
1212
*/
1313
const parseComment = (commentNode, indent, trim = true) => {
14+
const skipSeeLink = (parser) => {
15+
return (str, data) => {
16+
if (data.tag === 'see' && str.match(/{@link.+?}/)) {
17+
return null;
18+
}
19+
20+
return parser(str, data);
21+
}
22+
};
23+
1424
// Preserve JSDoc block start/end indentation.
1525
return commentParser(`${indent}/*${commentNode.value}${indent}*/`, {
1626
// @see https://github.com/yavorskiy/comment-parser/issues/21
1727
parsers: [
1828
commentParser.PARSERS.parse_tag,
19-
(str, data) => {
20-
if (data.tag === 'see') {
21-
// @see can't contain types, only names or links which might be confused with types
22-
return null;
23-
}
24-
25-
return commentParser.PARSERS.parse_type(str, data);
26-
},
27-
(str, data) => {
28-
if (['example', 'return', 'returns', 'throws', 'exception'].includes(data.tag)) {
29-
return null;
30-
}
31-
if (data.tag === 'see' && str.match(/{@link.+?}/)) {
32-
return null;
33-
}
29+
skipSeeLink(commentParser.PARSERS.parse_type),
30+
skipSeeLink(
31+
(str, data) => {
32+
if (['example', 'return', 'returns', 'throws', 'exception'].includes(data.tag)) {
33+
return null;
34+
}
3435

35-
return commentParser.PARSERS.parse_name(str, data);
36-
},
36+
return commentParser.PARSERS.parse_name(str, data);
37+
},
38+
),
3739
trim ?
3840
commentParser.PARSERS.parse_description :
3941

0 commit comments

Comments
 (0)