Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api-documenter] Print out tag name for unknown block tags #1296

Merged
merged 6 commits into from
Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/api-documenter/src/markdown/MarkdownEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
DocSection,
DocNodeTransforms,
DocEscapedText,
DocErrorText
DocErrorText,
DocBlockTag
} from '@microsoft/tsdoc';
import { InternalError } from '@microsoft/node-core-library';

Expand Down Expand Up @@ -191,8 +192,13 @@ export class MarkdownEmitter {
case DocNodeKind.InlineTag: {
break;
}
case DocNodeKind.BlockTag: {
const tagNode: DocBlockTag = docNode as DocBlockTag;
console.warn('Unsupported block tag: ' + tagNode.tagName);
break;
}
default:
throw new Error('Unsupported element kind: ' + docNode.kind);
throw new InternalError('Unsupported DocNodeKind kind: ' + docNode.kind);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
DocSoftBreak,
DocLinkTag,
DocHtmlStartTag,
DocHtmlEndTag
DocHtmlEndTag,
DocBlockTag
} from '@microsoft/tsdoc';

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

output.appendNodes([
new DocHeading({ configuration, title: 'Unknown block tag' }),
new DocParagraph({ configuration },
[
new DocBlockTag({
configuration,
tagName: '@unknown'
}),
new DocEmphasisSpan({ configuration, bold: true },
[ new DocPlainText({ configuration, text: 'bold' }) ]
),
new DocPlainText({ configuration, text: 'non-bold' }),
new DocPlainText({ configuration, text: 'more-non-bold' })
]
)
]);

output.appendNodes([
new DocHeading({ configuration, title: 'Bad characters' }),
new DocParagraph({ configuration },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ This is a <b>bold</b> word.

[a link](./index.md)<!-- --><b>bold</b>non-boldmore-non-bold

## Unknown block tag

<b>bold</b>non-boldmore-non-bold

## Bad characters

<b>\\\\*one\\\\*two\\\\*</b><b>three\\\\*four</b>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@microsoft/api-documenter",
"comment": "Avoid reporting a fatal error when an unknown block tag is encountered",
"type": "patch"
}
],
"packageName": "@microsoft/api-documenter",
"email": "[email protected]"
}
4 changes: 4 additions & 0 deletions common/config/rush/nonbrowser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@
"name": "clean-css",
"allowedCategories": [ "libraries" ]
},
{
"name": "cli-table",
"allowedCategories": [ "libraries" ]
},
{
"name": "colors",
"allowedCategories": [ "libraries", "tests" ]
Expand Down