[clang-tools-extra] [clang-doc] Display enum type along with enum name in HTML view (PR #181347)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 19 09:30:40 PST 2026
================
@@ -156,10 +156,18 @@ static void writeNameLink(const StringRef &CurrentPath, const Reference &R,
static void genMarkdown(const ClangDocContext &CDCtx, const EnumInfo &I,
llvm::raw_ostream &OS) {
- if (I.Scoped)
- writeLine("| enum class " + I.Name + " |", OS);
- else
- writeLine("| enum " + I.Name + " |", OS);
+ std::string Header = "| enum ";
+ if(I.Scoped)
+ Header += "class ";
+ Header += I.Name;
+ Header += " ";
+ if(I.BaseType && I.BaseType->Type.QualName != "") {
+ Header += ": ";
+ Header += I.BaseType->Type.QualName;
+ Header += " ";
+ }
+ Header += "|";
+ writeLine(Header, OS);
----------------
ilovepi wrote:
I know we have `writeLine`, but this honestly seems like a more appropriate thing to use as stream operations. There's probably a complex way to write this as a set of Twine operations that's even better, but for simplicity lets just write these to the stream and call it a day. An alternative would be to use something like `llvm::formatv()` or one of its variants for a printf like interface.
Additionally, why check `string != ""` over `.empty()`? And just for the future, you don't need to put every string concatenation on its own line.
https://github.com/llvm/llvm-project/pull/181347
More information about the cfe-commits
mailing list