Skip to content

Commit a6b3e8f

Browse files
committed
Print out tag name for unknown block tags
1 parent 92e9491 commit a6b3e8f

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

apps/api-documenter/src/markdown/MarkdownEmitter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
DocSection,
1616
DocNodeTransforms,
1717
DocEscapedText,
18-
DocErrorText
18+
DocErrorText,
19+
DocBlockTag
1920
} from '@microsoft/tsdoc';
2021
import { InternalError } from '@microsoft/node-core-library';
2122

@@ -191,8 +192,13 @@ export class MarkdownEmitter {
191192
case DocNodeKind.InlineTag: {
192193
break;
193194
}
195+
case DocNodeKind.BlockTag: {
196+
const tagNode: DocBlockTag = docNode as DocBlockTag;
197+
console.warn('Unsupported block tag: ' + tagNode.tagName);
198+
break;
199+
}
194200
default:
195-
throw new Error('Unsupported element kind: ' + docNode.kind);
201+
console.warn('Unsupported element kind: ' + docNode.kind);
196202
}
197203
}
198204

apps/api-documenter/src/markdown/test/CustomMarkdownEmitter.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
DocSoftBreak,
1111
DocLinkTag,
1212
DocHtmlStartTag,
13-
DocHtmlEndTag
13+
DocHtmlEndTag,
14+
DocBlockTag
1415
} from '@microsoft/tsdoc';
1516

1617
import { CustomDocNodes } from '../../nodes/CustomDocNodeKind';
@@ -131,6 +132,23 @@ test('render Markdown from TSDoc', () => {
131132
)
132133
]);
133134

135+
output.appendNodes([
136+
new DocHeading({ configuration, title: 'Unknown block tag' }),
137+
new DocParagraph({ configuration },
138+
[
139+
new DocBlockTag({
140+
configuration,
141+
tagName: '@unknown'
142+
}),
143+
new DocEmphasisSpan({ configuration, bold: true },
144+
[ new DocPlainText({ configuration, text: 'bold' }) ]
145+
),
146+
new DocPlainText({ configuration, text: 'non-bold' }),
147+
new DocPlainText({ configuration, text: 'more-non-bold' })
148+
]
149+
)
150+
]);
151+
134152
output.appendNodes([
135153
new DocHeading({ configuration, title: 'Bad characters' }),
136154
new DocParagraph({ configuration },

apps/api-documenter/src/markdown/test/__snapshots__/CustomMarkdownEmitter.test.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ This is a <b>bold</b> word.
2828
2929
[a link](./index.md)<!-- --><b>bold</b>non-boldmore-non-bold
3030
31+
## Unknown block tag
32+
33+
<b>bold</b>non-boldmore-non-bold
34+
3135
## Bad characters
3236
3337
<b>\\\\*one\\\\*two\\\\*</b><b>three\\\\*four</b>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-documenter",
5+
"comment": "print out tag name for unknown block tags",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft/api-documenter",
10+
"email": "enjoyjava@gmail.com"
11+
}

0 commit comments

Comments
 (0)