[clang-tools-extra] [Clang-doc] Display values and comments in MD (PR #183754)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 11:02:34 PST 2026
================
@@ -163,13 +187,37 @@ static void genMarkdown(const ClangDocContext &CDCtx, const EnumInfo &I,
if (I.BaseType && !I.BaseType->Type.QualName.empty()) {
OS << ": " << I.BaseType->Type.QualName << " ";
}
- OS << "|\n\n" << "--\n\n";
+ OS << "|\n\n";
std::string Buffer;
llvm::raw_string_ostream Members(Buffer);
- if (!I.Members.empty())
- for (const auto &N : I.Members)
- Members << "| " << N.Name << " |\n";
+ Members << "| Name | Value |";
+ if (!I.Members.empty()) {
+ bool HasComments = false;
+ for (const auto &Member : I.Members) {
+ if (!Member.Description.empty()) {
+ HasComments = true;
+ Members << " Comments |";
+ break;
+ }
+ }
+ Members << "\n";
+ Members << "|:-:|:-:|";
+ if (HasComments)
+ Members << ":-:|";
+ Members << "\n";
+ for (const auto &N : I.Members) {
+ Members << "| " << N.Name << " ";
+ if (!N.Value.empty())
+ Members << "| " << N.Value << " ";
+ if (HasComments) {
+ std::string RawComment =
+ StringRef(genRawText(N.Description)).trim().str();
----------------
ilovepi wrote:
Whats going on here? you're making a new string, creating a stringref, trimming it and then making another new string? why not just store the raw string, and then since you just use it in the output stream just use it there? or make the trimmed StringRef just after this and then use that below? it would avoid at least 2 copies, since you broke the copy elistion/move at the call site.
https://github.com/llvm/llvm-project/pull/183754
More information about the cfe-commits
mailing list