Skip to content

Commit afb61fa

Browse files
committed
Extend jsDocCompatibility with inheritDoc + brace opts
1 parent 1e96a2d commit afb61fa

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- Improved error messaging if a provided entry point could not be converted into a documented module reflection, #2242.
66
- API: Added support for `g`, `circle`, `ellipse`, `polygon`, and `polyline` svg elements, #2259.
7+
- Extended `jsDocCompatibility` option with `inheritDocTag` to ignore fully lowercase `inheritDoc` tags and
8+
`ignoreUnescapedBraces` to disable warnings about unescaped `{` and `}` characters in comments.
79

810
### Bug Fixes
911

src/lib/converter/comments/parser.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,12 @@ function blockContent(
342342

343343
case TokenSyntaxKind.Tag:
344344
if (next.text === "@inheritdoc") {
345-
warning(
346-
"The @inheritDoc tag should be properly capitalized",
347-
next
348-
);
345+
if (!config.jsDocCompatibility.inheritDocTag) {
346+
warning(
347+
"The @inheritDoc tag should be properly capitalized",
348+
next
349+
);
350+
}
349351
next.text = "@inheritDoc";
350352
}
351353
if (config.modifierTags.has(next.text)) {
@@ -371,7 +373,9 @@ function blockContent(
371373

372374
case TokenSyntaxKind.CloseBrace:
373375
// Unmatched closing brace, generate a warning, and treat it as text.
374-
warning(`Unmatched closing brace`, next);
376+
if (!config.jsDocCompatibility.ignoreUnescapedBraces) {
377+
warning(`Unmatched closing brace`, next);
378+
}
375379
content.push({ kind: "text", text: next.text });
376380
break;
377381

@@ -433,10 +437,12 @@ function inlineTag(
433437
lexer.done() ||
434438
![TokenSyntaxKind.Text, TokenSyntaxKind.Tag].includes(lexer.peek().kind)
435439
) {
436-
warning(
437-
"Encountered an unescaped open brace without an inline tag",
438-
openBrace
439-
);
440+
if (!config.jsDocCompatibility.ignoreUnescapedBraces) {
441+
warning(
442+
"Encountered an unescaped open brace without an inline tag",
443+
openBrace
444+
);
445+
}
440446
block.push({ kind: "text", text: openBrace.text });
441447
return;
442448
}
@@ -449,10 +455,12 @@ function inlineTag(
449455
(!/^\s+$/.test(tagName.text) ||
450456
lexer.peek().kind != TokenSyntaxKind.Tag))
451457
) {
452-
warning(
453-
"Encountered an unescaped open brace without an inline tag",
454-
openBrace
455-
);
458+
if (!config.jsDocCompatibility.ignoreUnescapedBraces) {
459+
warning(
460+
"Encountered an unescaped open brace without an inline tag",
461+
openBrace
462+
);
463+
}
456464
block.push({ kind: "text", text: openBrace.text + tagName.text });
457465
return;
458466
}

src/lib/utils/options/declaration.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,16 @@ export type JsDocCompatibility = {
222222
* On by default, this is how VSCode renders blocks.
223223
*/
224224
defaultTag: boolean;
225+
/**
226+
* If set, TypeDoc will warn if a `@inheritDoc` tag is spelled without TSDoc capitalization
227+
* (i.e. `@inheritdoc`). On by default.
228+
*/
229+
inheritDocTag: boolean;
230+
/**
231+
* If set, TypeDoc will not emit warnings about unescaped `{` and `}` characters encountered
232+
* when parsing a comment. On by default.
233+
*/
234+
ignoreUnescapedBraces: boolean;
225235
};
226236

227237
/**

src/lib/utils/options/sources/typedoc.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
530530
defaults: {
531531
defaultTag: true,
532532
exampleTag: true,
533+
inheritDocTag: true,
534+
ignoreUnescapedBraces: true,
533535
},
534536
});
535537

0 commit comments

Comments
 (0)