Extracts Doxygen style comment blocks from the comment.
39{
40 const auto *comment =
41 decl.getASTContext().getRawCommentForDeclNoCache(&decl);
42
43 if (comment == nullptr) {
44 return;
45 }
46
48
49 auto formatted_comment = comment->getFormattedText(
51
53 cmt["raw"] = raw_comment;
54 cmt["formatted"] = formatted_comment;
55
56 using clang::comments::BlockCommandComment;
57 using clang::comments::FullComment;
58 using clang::comments::ParagraphComment;
59 using clang::comments::ParamCommandComment;
60 using clang::comments::TextComment;
61 using clang::comments::TParamCommandComment;
62
63 FullComment *full_comment =
64 comment->parse(decl.getASTContext(), nullptr, &decl);
65
66 const auto &traits = decl.getASTContext().getCommentCommandTraits();
67
68 for (const auto *block : full_comment->getBlocks()) {
69 const auto block_kind = block->getCommentKind();
71 std::string paragraph_text;
72
74 paragraph_text);
75 if (!cmt.contains("text"))
76 cmt["text"] = "";
77
78 cmt["text"] =
79 cmt["text"].get<std::string>() + "\n" + paragraph_text;
80
81 if (!cmt.contains("paragraph"))
82 cmt["paragraph"] = inja::json::array();
83
84 cmt["paragraph"].push_back(paragraph_text);
85 }
87
88 }
89 else if (block_kind ==
92 clang::dyn_cast<ParamCommandComment>(block), traits, cmt);
93 }
94 else if (block_kind ==
97 clang::dyn_cast<TParamCommandComment>(block), traits, cmt);
98 }
99 else if (block_kind ==
101 if (const auto *command =
102 clang::dyn_cast<BlockCommandComment>(block);
103 command != nullptr) {
104 const auto *command_info =
105 traits.getCommandInfo(command->getCommandID());
106
107 if (command_info->IsBlockCommand &&
108 command_info->NumArgs == 0U) {
109
110
111
112
114 }
115 else if (command_info->IsParamCommand) {
116
117
119 clang::dyn_cast<ParamCommandComment>(command), traits,
120 cmt);
121 }
122 else if (command_info->IsTParamCommand) {
123
124
126 clang::dyn_cast<TParamCommandComment>(command), traits,
127 cmt);
128 }
129 }
130 }
131 }
132 e.set_comment(cmt);
133}