-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-doc] add throws comments to comment template #150649
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
Conversation
|
@llvm/pr-subscribers-clang-tools-extra Author: Erick Velez (evelez7) ChangesSerialize throw Doxygen comments for exceptions. Accepts both \throw and Full diff: https://github.com/llvm/llvm-project/pull/150649.diff 2 Files Affected:
diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 599b381cea60d..2db6451259f60 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -140,6 +140,13 @@ static Object serializeComment(const CommentInfo &I, Object &Description) {
insertComment(Description, TextCommentsArray, "BriefComments");
else if (I.Name == "return")
insertComment(Description, TextCommentsArray, "ReturnComments");
+ else if (I.Name == "throws" || I.Name == "throw") {
+ json::Value ThrowsVal = Object();
+ auto &ThrowsObj = *ThrowsVal.getAsObject();
+ ThrowsObj["Exception"] = I.Args.front();
+ ThrowsObj["Children"] = TextCommentsArray;
+ insertComment(Description, ThrowsVal, "ThrowsComments");
+ }
return Obj;
}
diff --git a/clang-tools-extra/clang-doc/assets/comment-template.mustache b/clang-tools-extra/clang-doc/assets/comment-template.mustache
index 4e38e5fb92d18..60a4c70ec0dc4 100644
--- a/clang-tools-extra/clang-doc/assets/comment-template.mustache
+++ b/clang-tools-extra/clang-doc/assets/comment-template.mustache
@@ -54,6 +54,14 @@
</div>
{{/CodeComments}}
{{/HasCodeComments}}
+{{#HasThrowsComments}}
+ <h3>Throws</h3>
+ {{#ThrowsComments}}
+ <div>
+ <b>{{ThrowName}}</b> {{#Children}}{{>Comments}}{{/Children}}
+ </div>
+ {{/ThrowsComments}}
+{{/HasThrowsComments}}
{{#BlockCommandComment}}
<div class="block-command-comment__command">
<div class="block-command-command">
|
26f70f8 to
e736a45
Compare
9543783 to
7d6c38c
Compare
e736a45 to
ff3d3ad
Compare
7d6c38c to
e8795d0
Compare
ff3d3ad to
eb95d56
Compare
1ef0736 to
3dbfb45
Compare
3dbfb45 to
9c3d458
Compare
eb95d56 to
35762dd
Compare
|
Think I lost track of this during GSoC submission. Should still be valid. |
ilovepi
left a comment
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.
LGTM. It'd be nice if that HTML output looked sane, but if the tests still pass, its probably fine.
|
The extra What these two have in common is that they recursively call the comment partial to render the text comments.
There's no |
So what seems to be happening is that the div's aren't mismatched. I took the raw html from that link and threw it into a formatter. I think the fact that that's only the FileCheck output and matching is kind of fuzzy is what's going on. We're not using |
|
As for why those dive are showing up, I'd guess one of the internal partials for paragraph comment or something is gettting matched when we process the children and you end up w/ more |
Serialize throw Doxygen comments for exceptions. Accepts both \throw and \throws.
35762dd to
45a83f5
Compare
|
I found the issue with the
the Also yes, the wrong placeholder was being named for the exception. Updated the link to verify: https://erickvelez.com/clang-doc-mustache-output/pr150649/GlobalNamespace/_ZTV10Calculator.html |
ilovepi
left a comment
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.
Thanks for running that down. This looks great now.

Serialize throw Doxygen comments for exceptions. Accepts both \throw and
\throws.