-
Notifications
You must be signed in to change notification settings - Fork 604
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
Conversation
71a06fa
to
62355c2
Compare
api-documenter definitely should not be crashing for these inputs. We should fix that in this PR, at the very least. But I'm not sure that the documentation tool render these blocks. For a commercial company, it can be embarrassing to have unprofessional get rendered on your public website. As a general policy, when we encounter an unrecognized TSDoc tag, it's safer to omit it than to render it. Some specific thoughts on that:
|
@octogonz Thank you for the input. In my case, the first step is to make sure unknown tags do NOT crash api-documenter. We should warn that such tags are ignored so that they can be fixed if it's there by mistake. Let me improve the PR to not throw an error. |
62355c2
to
a6b3e8f
Compare
Agreed
Doesn't the |
@octogonz Can you elaborate |
If you paste your comment into the TSDoc playground, you should see that warning being reported. And the default api-extractor.json should report it ( |
tsdoc may be showing a warning, but it looks like api-documenter throws an error by default. |
Agreed, looks like @raymondfeng already pushed a fix that addresses my concern above. I'll get this merged. |
default: | ||
throw new Error('Unsupported element kind: ' + docNode.kind); | ||
console.warn('Unsupported element kind: ' + docNode.kind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@halfnibble This change was not safe in my opinion: If API Documenter does not recognize some part of the TSDoc syntax tree, that's a bug. We would want people to report an error, so we can determine a correct handling of that node.
Whereas if API Documenter silently ignored the unrecognized node, then it would be simply omitted from the output. It could be years before we eventually realized that we forgot to implement it. Note that it's okay to ignore an unsupported tag; here I'm referring to a generalized node in the tree.
This concern is particularly important since currently API Extractor / API Documenter are serving as the reference implementation of the TSDoc standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a fix.
We ran into various cases that tsdoc comments have unknown block tags, such as:
Without this PR, api-documenter just aborts with Unsupported element kind: BlockTag. The error message is meaningless and it does not help fix the underlying issue.
I would also like to know what source TS file (line/column) has the invalid tag. Please let me know how to access such metadata so that I can improve this PR.