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 @@ {{/CodeComments}} {{/HasCodeComments}} +{{#HasThrowsComments}} +

Throws

+ {{#ThrowsComments}} +
+ {{ThrowName}} {{#Children}}{{>Comments}}{{/Children}} +
+ {{/ThrowsComments}} +{{/HasThrowsComments}} {{#BlockCommandComment}}
diff --git a/clang-tools-extra/test/clang-doc/basic-project.mustache.test b/clang-tools-extra/test/clang-doc/basic-project.mustache.test index e2d9da60183fa..88317393bb26c 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test +++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test @@ -384,6 +384,10 @@ HTML-CALC:
HTML-CALC:

Returns

HTML-CALC:

double The result of a / b.

HTML-CALC:

+HTML-CALC:

Throws

+HTML-CALC:
+HTML-CALC:
+HTML-CALC:

if b is zero.

HTML-CALC:
HTML-CALC:
HTML-CALC: