[clang-tools-extra] [clang-doc] Remove deprecated Markdown generator (PR #209071)
Erick Velez via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 12 18:52:29 PDT 2026
https://github.com/evelez7 created https://github.com/llvm/llvm-project/pull/209071
Focus is shifting to the Mustache-backed Markdown generator which is now called by `--format=md`. Any potential gaps in functionality are documented in #201945.
>From f7581bfdb9ef9586d65f1a0b3dbbe39390af99b5 Mon Sep 17 00:00:00 2001
From: Erick Velez <erickvelez7 at gmail.com>
Date: Sun, 12 Jul 2026 18:47:21 -0700
Subject: [PATCH] [clang-doc] Remove deprecated Markdown generator
Focus is shifting to the Mustache-backed Markdown generator which is now
called by `--format=md`. Any potential gaps in functionality are
documented in #201945.
---
clang-tools-extra/clang-doc/CMakeLists.txt | 1 -
clang-tools-extra/clang-doc/Generators.cpp | 2 -
clang-tools-extra/clang-doc/Generators.h | 1 -
clang-tools-extra/clang-doc/JSONGenerator.cpp | 2 +-
clang-tools-extra/clang-doc/MDGenerator.cpp | 660 +++---------------
.../clang-doc/MDMustacheGenerator.cpp | 121 ----
clang-tools-extra/clang-doc/Representation.h | 2 +-
.../clang-doc/tool/ClangDocMain.cpp | 29 +-
.../clang-doc/basic-project.mustache.test | 2 +-
.../test/clang-doc/basic-project.test | 127 +---
.../test/clang-doc/md/array-type.cpp | 5 +-
.../test/clang-doc/md/builtin_types.cpp | 36 +-
.../md/class-partial-specialization.cpp | 5 +-
.../test/clang-doc/md/comments-in-macros.cpp | 15 +-
clang-tools-extra/test/clang-doc/md/enum.cpp | 114 +--
.../clang-doc/md/function-pointer-type.cpp | 5 +-
.../md/member-function-pointer-type.cpp | 5 +-
.../test/clang-doc/md/namespace.cpp | 144 +---
.../md/nested-pointer-qualifiers.cpp | 3 -
.../test/clang-doc/md/templates.cpp | 28 +-
.../unittests/clang-doc/CMakeLists.txt | 1 -
.../unittests/clang-doc/MDGeneratorTest.cpp | 428 ------------
22 files changed, 158 insertions(+), 1578 deletions(-)
delete mode 100644 clang-tools-extra/clang-doc/MDMustacheGenerator.cpp
delete mode 100644 clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
diff --git a/clang-tools-extra/clang-doc/CMakeLists.txt b/clang-tools-extra/clang-doc/CMakeLists.txt
index 438888c1e5e13..f4d86e8830a6b 100644
--- a/clang-tools-extra/clang-doc/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/CMakeLists.txt
@@ -18,7 +18,6 @@ add_clang_library(clangDoc STATIC
Serialize.cpp
YAMLGenerator.cpp
JSONGenerator.cpp
- MDMustacheGenerator.cpp
DEPENDS
omp_gen
diff --git a/clang-tools-extra/clang-doc/Generators.cpp b/clang-tools-extra/clang-doc/Generators.cpp
index 5ff1a5c0a4eb2..c0933f06c1789 100644
--- a/clang-tools-extra/clang-doc/Generators.cpp
+++ b/clang-tools-extra/clang-doc/Generators.cpp
@@ -252,7 +252,5 @@ void Generator::addInfoToIndex(Index &Idx, const doc::Info *Info) {
[[maybe_unused]] static int MDGeneratorAnchorDest = MDGeneratorAnchorSource;
[[maybe_unused]] static int HTMLGeneratorAnchorDest = HTMLGeneratorAnchorSource;
[[maybe_unused]] static int JSONGeneratorAnchorDest = JSONGeneratorAnchorSource;
-[[maybe_unused]] static int MDMustacheGeneratorAnchorDest =
- MDMustacheGeneratorAnchorSource;
} // namespace doc
} // namespace clang
diff --git a/clang-tools-extra/clang-doc/Generators.h b/clang-tools-extra/clang-doc/Generators.h
index fc7fdb515ee4f..7b2d5c7f97f5e 100644
--- a/clang-tools-extra/clang-doc/Generators.h
+++ b/clang-tools-extra/clang-doc/Generators.h
@@ -144,7 +144,6 @@ extern volatile int YAMLGeneratorAnchorSource;
extern volatile int MDGeneratorAnchorSource;
extern volatile int HTMLGeneratorAnchorSource;
extern volatile int JSONGeneratorAnchorSource;
-extern volatile int MDMustacheGeneratorAnchorSource;
} // namespace doc
} // namespace clang
diff --git a/clang-tools-extra/clang-doc/JSONGenerator.cpp b/clang-tools-extra/clang-doc/JSONGenerator.cpp
index 1a15618b14bf4..58995c249bd21 100644
--- a/clang-tools-extra/clang-doc/JSONGenerator.cpp
+++ b/clang-tools-extra/clang-doc/JSONGenerator.cpp
@@ -1023,7 +1023,7 @@ Error JSONGenerator::generateDocumentation(StringRef RootDir,
Info->DocumentationFileName = internString(FileName);
}
- if (CDCtx.Format == OutputFormatTy::md_mustache) {
+ if (CDCtx.Format == OutputFormatTy::md) {
Markdown = true;
if (auto Err = serializeAllFiles(CDCtx, RootDir))
return Err;
diff --git a/clang-tools-extra/clang-doc/MDGenerator.cpp b/clang-tools-extra/clang-doc/MDGenerator.cpp
index 2129880c890f4..f496f1fc44f9d 100644
--- a/clang-tools-extra/clang-doc/MDGenerator.cpp
+++ b/clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -1,615 +1,119 @@
-//===-- MDGenerator.cpp - Markdown Generator --------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation of the MDGenerator, which
+/// generates documentation in Markdown format using Mustache templates. It
+/// defines how the structured data in Info objects is mapped to template
+/// tags to produce readable markdown documents.
+///
+//===----------------------------------------------------------------------===//
#include "Generators.h"
-#include "Representation.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/FormatVariadic.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/raw_ostream.h"
-#include <string>
using namespace llvm;
using namespace clang::doc;
-// Markdown generation
-
-static std::string genItalic(const Twine &Text) {
- return "*" + Text.str() + "*";
-}
-
-static std::string genEmphasis(const Twine &Text) {
- return "**" + Text.str() + "**";
-}
-
-static std::string genReferenceList(llvm::ArrayRef<Reference> Refs) {
- std::string Buffer;
- llvm::raw_string_ostream Stream(Buffer);
- for (const auto &R : Refs) {
- if (&R != Refs.begin())
- Stream << ", ";
- Stream << R.Name;
- }
- return Stream.str();
-}
-
-static void writeLine(const Twine &Text, raw_ostream &OS) {
- OS << Text << "\n\n";
-}
-
-static void writeNewLine(raw_ostream &OS) { OS << "\n\n"; }
-
-static void writeHeader(const Twine &Text, unsigned int Num, raw_ostream &OS) {
- OS << std::string(Num, '#') + " " + Text << "\n\n";
-}
+static std::unique_ptr<MustacheTemplateFile> RecordTemplate = nullptr;
-static void writeSourceFileRef(const ClangDocContext &CDCtx, const Location &L,
- raw_ostream &OS) {
+static std::unique_ptr<MustacheTemplateFile> NamespaceTemplate = nullptr;
- if (!CDCtx.RepositoryUrl) {
- OS << "*Defined at " << L.Filename << "#"
- << std::to_string(L.StartLineNumber) << "*";
- } else {
+static std::unique_ptr<MustacheTemplateFile> AllFilesTemplate = nullptr;
- OS << formatv("*Defined at [#{0}{1}{2}](#{0}{1}{3})*",
- CDCtx.RepositoryLinePrefix.value_or(""), L.StartLineNumber,
- L.Filename, *CDCtx.RepositoryUrl);
- }
- OS << "\n\n";
-}
-
-/// Writer for writing comments to a table cell in MD.
-///
-/// The writer traverses the comments recursively and outputs the
-/// comments into a stream.
-/// The formatter inserts single/double line breaks to retain the comment
-/// structure.
-///
-/// Usage :
-/// Initialize an object with a llvm::raw_ostream to output into.
-/// Call the write(C) function with an array of Comments 'C'.
-class TableCommentWriter {
-public:
- explicit TableCommentWriter(llvm::raw_ostream &OS) : OS(OS) {}
-
- void write(const DocList<CommentInfo> &Comments) {
- for (const auto &C : Comments)
- writeTableSafeComment(C);
-
- if (!Started)
- OS << "--";
- }
-
-private:
- /// This function inserts breaks into the stream.
- ///
- /// We add a double break in between paragraphs.
- /// Inside a paragraph, a single break between lines is maintained.
- void insertSeparator() {
- if (!Started)
- return;
- if (NeedsParagraphBreak) {
- OS << "<br><br>";
- NeedsParagraphBreak = false;
- } else {
- OS << "<br>";
- }
- }
-
- /// This function processes every comment and its children recursively.
- void writeTableSafeComment(const CommentInfo &I) {
- switch (I.Kind) {
- case CommentKind::CK_FullComment:
- for (const auto &Child : I.Children)
- writeTableSafeComment(Child);
- break;
-
- case CommentKind::CK_ParagraphComment:
- for (const auto &Child : I.Children)
- writeTableSafeComment(Child);
- // Next content after a paragraph needs a break
- NeedsParagraphBreak = true;
- break;
-
- case CommentKind::CK_TextComment:
- if (!I.Text.empty()) {
- insertSeparator();
- OS << I.Text;
- Started = true;
- }
- break;
-
- // Handle other comment types (BlockCommand, InlineCommand, etc.)
- default:
- for (const auto &Child : I.Children)
- writeTableSafeComment(Child);
- break;
- }
- }
-
- llvm::raw_ostream &OS;
- bool Started = false;
- bool NeedsParagraphBreak = false;
-};
-
-static void maybeWriteSourceFileRef(llvm::raw_ostream &OS,
- const ClangDocContext &CDCtx,
- const std::optional<Location> &DefLoc) {
- if (DefLoc)
- writeSourceFileRef(CDCtx, *DefLoc, OS);
-}
-
-static void writeDescription(const CommentInfo &I, raw_ostream &OS) {
- switch (I.Kind) {
- case CommentKind::CK_FullComment:
- for (const auto &Child : I.Children)
- writeDescription(Child, OS);
- break;
-
- case CommentKind::CK_ParagraphComment:
- for (const auto &Child : I.Children)
- writeDescription(Child, OS);
- writeNewLine(OS);
- break;
-
- case CommentKind::CK_BlockCommandComment:
- OS << genEmphasis(I.Name) << " ";
- for (const auto &Child : I.Children)
- writeDescription(Child, OS);
- break;
-
- case CommentKind::CK_InlineCommandComment:
- OS << genEmphasis(I.Name) << " " << I.Text;
- break;
-
- case CommentKind::CK_ParamCommandComment:
- case CommentKind::CK_TParamCommandComment: {
- std::string Direction = I.Explicit ? (" " + I.Direction).str() : "";
- OS << genEmphasis(I.ParamName) << I.Text << Direction << " ";
- for (const auto &Child : I.Children)
- writeDescription(Child, OS);
- break;
- }
-
- case CommentKind::CK_VerbatimBlockComment:
- for (const auto &Child : I.Children)
- writeDescription(Child, OS);
- break;
-
- case CommentKind::CK_VerbatimBlockLineComment:
- case CommentKind::CK_VerbatimLineComment:
- OS << I.Text;
- writeNewLine(OS);
- break;
-
- case CommentKind::CK_HTMLStartTagComment: {
- if (I.AttrKeys.size() != I.AttrValues.size())
- return;
- std::string Buffer;
- llvm::raw_string_ostream Attrs(Buffer);
- for (unsigned Idx = 0; Idx < I.AttrKeys.size(); ++Idx)
- Attrs << " \"" << I.AttrKeys[Idx] << "=" << I.AttrValues[Idx] << "\"";
-
- std::string CloseTag = I.SelfClosing ? "/>" : ">";
- writeLine("<" + I.Name + Attrs.str() + CloseTag, OS);
- break;
- }
-
- case CommentKind::CK_HTMLEndTagComment:
- writeLine("</" + I.Name + ">", OS);
- break;
-
- case CommentKind::CK_TextComment:
- OS << I.Text;
- break;
-
- case CommentKind::CK_Unknown:
- OS << "Unknown comment kind: " << static_cast<int>(I.Kind) << ".\n\n";
- break;
- }
-}
-
-static void writeNameLink(const StringRef &CurrentPath, const Reference &R,
- llvm::raw_ostream &OS) {
- llvm::SmallString<64> Path = R.getRelativeFilePath(CurrentPath);
- // Paths in Markdown use POSIX separators.
- llvm::sys::path::native(Path, llvm::sys::path::Style::posix);
- llvm::sys::path::append(Path, llvm::sys::path::Style::posix,
- R.getFileBaseName() + ".md");
- OS << "[" << R.Name << "](" << Path << ")";
-}
-
-static void genMarkdown(const ClangDocContext &CDCtx, const EnumInfo &I,
- llvm::raw_ostream &OS) {
- OS << "| enum ";
- if (I.Scoped)
- OS << "class ";
- OS << (I.Name.empty() ? "(unnamed)" : StringRef(I.Name)) << " ";
- if (I.BaseType && !I.BaseType->Type.QualName.empty()) {
- OS << ": " << I.BaseType->Type.QualName << " ";
- }
- OS << "|\n\n";
-
- OS << "| Name | Value |";
- if (!I.Members.empty()) {
- bool HasComments = false;
- for (const auto &Member : I.Members) {
- if (!Member.Description.empty()) {
- HasComments = true;
- OS << " Comments |";
- break;
- }
- }
- OS << "\n|---|---|";
- if (HasComments)
- OS << "---|";
- OS << "\n";
- for (const auto &N : I.Members) {
- OS << "| " << N.Name << " ";
- if (!N.Value.empty())
- OS << "| " << N.Value << " ";
- if (HasComments) {
- OS << "| ";
- TableCommentWriter CommentWriter(OS);
- CommentWriter.write(N.Description);
- OS << " ";
- }
- OS << "|\n";
- }
- }
- OS << "\n";
-
- maybeWriteSourceFileRef(OS, CDCtx, I.DefLoc);
-
- for (const auto &C : I.Description)
- writeDescription(C, OS);
-}
-
-static void genMarkdown(const ClangDocContext &CDCtx, const FunctionInfo &I,
- llvm::raw_ostream &OS) {
- std::string Buffer;
- llvm::raw_string_ostream Stream(Buffer);
- bool First = true;
- for (const auto &N : I.Params) {
- if (!First)
- Stream << ", ";
- Stream << N.Type.QualName + " " + N.Name;
- First = false;
- }
- writeHeader(I.Name, 3, OS);
- StringRef Access = getAccessSpelling(I.Access);
- writeLine(genItalic(Twine(Access) + (!Access.empty() ? " " : "") +
- (I.IsStatic ? "static " : "") +
- I.ReturnType.Type.QualName.str() + " " + I.Name.str() +
- "(" + Twine(Stream.str()) + ")"),
- OS);
-
- maybeWriteSourceFileRef(OS, CDCtx, I.DefLoc);
-
- for (const auto &C : I.Description)
- writeDescription(C, OS);
-}
-
-static void genMarkdown(const ClangDocContext &CDCtx, const NamespaceInfo &I,
- llvm::raw_ostream &OS) {
- if (I.Name == "")
- writeHeader("Global Namespace", 1, OS);
- else
- writeHeader("namespace " + I.Name, 1, OS);
- writeNewLine(OS);
-
- if (!I.Description.empty()) {
- for (const auto &C : I.Description)
- writeDescription(C, OS);
- writeNewLine(OS);
- }
-
- llvm::SmallString<64> BasePath = I.getRelativeFilePath("");
-
- if (!I.Children.Namespaces.empty()) {
- writeHeader("Namespaces", 2, OS);
- for (const auto &R : I.Children.Namespaces) {
- OS << "* ";
- writeNameLink(BasePath, R, OS);
- OS << "\n";
- }
- writeNewLine(OS);
- }
-
- if (!I.Children.Records.empty()) {
- writeHeader("Records", 2, OS);
- for (const auto &R : I.Children.Records) {
- OS << "* ";
- writeNameLink(BasePath, R, OS);
- OS << "\n";
- }
- writeNewLine(OS);
- }
-
- if (!I.Children.Functions.empty()) {
- writeHeader("Functions", 2, OS);
- for (const auto &F : I.Children.Functions)
- genMarkdown(CDCtx, F, OS);
- writeNewLine(OS);
- }
- if (!I.Children.Enums.empty()) {
- writeHeader("Enums", 2, OS);
- for (const auto &E : I.Children.Enums)
- genMarkdown(CDCtx, E, OS);
- writeNewLine(OS);
- }
-}
-
-static void genMarkdown(const ClangDocContext &CDCtx, const RecordInfo &I,
- llvm::raw_ostream &OS) {
- writeHeader(getTagType(I.TagType) + " " + I.Name, 1, OS);
-
- maybeWriteSourceFileRef(OS, CDCtx, I.DefLoc);
-
- if (!I.Description.empty()) {
- for (const auto &C : I.Description)
- writeDescription(C, OS);
- writeNewLine(OS);
- }
-
- std::string Parents = genReferenceList(I.Parents);
- std::string VParents = genReferenceList(I.VirtualParents);
- if (!Parents.empty() || !VParents.empty()) {
- if (Parents.empty())
- writeLine("Inherits from " + VParents, OS);
- else if (VParents.empty())
- writeLine("Inherits from " + Parents, OS);
- else
- writeLine("Inherits from " + Parents + ", " + VParents, OS);
- writeNewLine(OS);
- }
-
- if (!I.Members.empty()) {
- writeHeader("Members", 2, OS);
- for (const auto &Member : I.Members) {
- StringRef Access = getAccessSpelling(Member.Access);
- writeLine(Twine(Access) + (Access.empty() ? "" : " ") +
- (Member.IsStatic ? "static " : "") +
- Member.Type.Name.str() + " " + Member.Name.str(),
- OS);
- }
- writeNewLine(OS);
- }
-
- if (!I.Children.Records.empty()) {
- writeHeader("Records", 2, OS);
- for (const auto &R : I.Children.Records)
- writeLine(R->Name, OS);
- writeNewLine(OS);
- }
- if (!I.Children.Functions.empty()) {
- writeHeader("Functions", 2, OS);
- for (const auto &F : I.Children.Functions)
- genMarkdown(CDCtx, F, OS);
- writeNewLine(OS);
- }
- if (!I.Children.Enums.empty()) {
- writeHeader("Enums", 2, OS);
- for (const auto &E : I.Children.Enums)
- genMarkdown(CDCtx, E, OS);
- writeNewLine(OS);
- }
-}
-
-static void genMarkdown(const ClangDocContext &CDCtx, const TypedefInfo &I,
- llvm::raw_ostream &OS) {
- // TODO support typedefs in markdown.
-}
-
-static void serializeReference(llvm::raw_fd_ostream &OS, const Index &I,
- int Level) {
- // Write out the heading level starting at ##
- OS << "##" << std::string(Level, '#') << " ";
- writeNameLink("", I, OS);
- OS << "\n";
-}
-
-static llvm::Error serializeIndex(ClangDocContext &CDCtx) {
- std::error_code FileErr;
- llvm::SmallString<128> FilePath;
- llvm::sys::path::native(CDCtx.OutDirectory, FilePath);
- llvm::sys::path::append(FilePath, "all_files.md");
- llvm::raw_fd_ostream OS(FilePath, FileErr, llvm::sys::fs::OF_Text);
- if (FileErr)
- return llvm::createStringError(llvm::inconvertibleErrorCode(),
- "error creating index file: " +
- FileErr.message());
-
- CDCtx.Idx.sort();
- OS << "# All Files";
- if (!CDCtx.ProjectName.empty())
- OS << " for " << CDCtx.ProjectName;
- OS << "\n\n";
-
- std::vector<const Index *> Children = CDCtx.Idx.getSortedChildren();
- for (const auto *C : Children)
- serializeReference(OS, *C, 0);
-
- return llvm::Error::success();
-}
-
-static llvm::Error genIndex(ClangDocContext &CDCtx) {
- std::error_code FileErr;
- llvm::SmallString<128> FilePath;
- llvm::sys::path::native(CDCtx.OutDirectory, FilePath);
- llvm::sys::path::append(FilePath, "index.md");
- llvm::raw_fd_ostream OS(FilePath, FileErr, llvm::sys::fs::OF_Text);
- if (FileErr)
- return llvm::createStringError(llvm::inconvertibleErrorCode(),
- "error creating index file: " +
- FileErr.message());
- CDCtx.Idx.sort();
- OS << "# " << CDCtx.ProjectName << " C/C++ Reference\n\n";
- std::vector<const Index *> Children = CDCtx.Idx.getSortedChildren();
- for (const auto *C : Children) {
- if (!C->Children.empty()) {
- const char *Type;
- switch (C->RefType) {
- case InfoType::IT_namespace:
- Type = "Namespace";
- break;
- case InfoType::IT_record:
- Type = "Type";
- break;
- case InfoType::IT_enum:
- Type = "Enum";
- break;
- case InfoType::IT_function:
- Type = "Function";
- break;
- case InfoType::IT_typedef:
- Type = "Typedef";
- break;
- case InfoType::IT_concept:
- Type = "Concept";
- break;
- case InfoType::IT_variable:
- Type = "Variable";
- break;
- case InfoType::IT_friend:
- Type = "Friend";
- break;
- case InfoType::IT_default:
- Type = "Other";
- }
- OS << "* " << Type << ": [" << C->Name << "](";
- if (!C->Path.empty())
- OS << C->Path << "/";
- OS << C->Name << ")\n";
- }
- }
- return llvm::Error::success();
-}
+static std::unique_ptr<MustacheTemplateFile> IndexTemplate = nullptr;
namespace {
-/// Generator for Markdown documentation.
-class MDGenerator : public Generator {
-public:
- static StringRef Format;
-
- llvm::Error generateDocumentation(StringRef RootDir,
- llvm::StringMap<Info *> Infos,
- const ClangDocContext &CDCtx,
- std::string DirName) override;
- llvm::Error createResources(ClangDocContext &CDCtx) override;
- llvm::Error generateDocForInfo(Info *I, llvm::raw_ostream &OS,
- const ClangDocContext &CDCtx) override;
+struct MDGenerator : public MustacheGenerator {
+ static const char *Format;
+ Error generateDocumentation(StringRef RootDir, StringMap<Info *> Infos,
+ const ClangDocContext &CDCtx,
+ std::string DirName) override;
+ Error setupTemplateFiles(const ClangDocContext &CDCtx) override;
+ Error generateDocForJSON(json::Value &JSON, raw_fd_ostream &OS,
+ const ClangDocContext &CDCtx,
+ StringRef ObjectTypeStr,
+ StringRef RelativeRootPath) override;
+ // This generator doesn't need this function, but it inherits from the
+ // original generator interface.
+ Error generateDocForInfo(Info *I, llvm::raw_ostream &OS,
+ const ClangDocContext &CDCtx) override;
};
} // namespace
-StringRef MDGenerator::Format = "md";
-
-llvm::Error MDGenerator::generateDocumentation(StringRef RootDir,
- llvm::StringMap<Info *> Infos,
- const ClangDocContext &CDCtx,
- std::string DirName) {
- // Track which directories we already tried to create.
- llvm::StringSet<> CreatedDirs;
-
- // Collect all output by file name and create the necessary directories.
- llvm::StringMap<std::vector<Info *>> FileToInfos;
- for (const auto &Group : Infos) {
- Info *Info = Group.getValue();
-
- llvm::SmallString<128> Path;
- llvm::sys::path::native(RootDir, Path);
- llvm::sys::path::append(Path, Info->getRelativeFilePath(""));
- if (!CreatedDirs.contains(Path)) {
- if (std::error_code Err = llvm::sys::fs::create_directories(Path);
- Err != std::error_code()) {
- return llvm::createStringError(Err, "Failed to create directory '%s'.",
- Path.c_str());
- }
- CreatedDirs.insert(Path);
- }
-
- llvm::sys::path::append(Path, Info->getFileBaseName() + ".md");
- FileToInfos[Path].push_back(Info);
- }
+Error MDGenerator::setupTemplateFiles(const ClangDocContext &CDCtx) {
+ std::string ClassFilePath = CDCtx.MustacheTemplates.lookup("class-template");
+ std::string NamespaceFilePath =
+ CDCtx.MustacheTemplates.lookup("namespace-template");
+ std::string AllFilesPath = CDCtx.MustacheTemplates.lookup("all-files");
+ std::string IndexFilePath = CDCtx.MustacheTemplates.lookup("index");
+ std::string CommentsFilePath = CDCtx.MustacheTemplates.lookup("comments");
+ std::vector<std::pair<StringRef, StringRef>> Partials = {
+ {"Comments", CommentsFilePath}};
+
+ if (Error Err = setupTemplate(RecordTemplate, ClassFilePath, Partials))
+ return Err;
+ if (Error Err = setupTemplate(NamespaceTemplate, NamespaceFilePath, Partials))
+ return Err;
+ if (Error Err = setupTemplate(AllFilesTemplate, AllFilesPath, Partials))
+ return Err;
+ if (Error Err = setupTemplate(IndexTemplate, IndexFilePath, Partials))
+ return Err;
- for (const auto &Group : FileToInfos) {
- std::error_code FileErr;
- llvm::raw_fd_ostream InfoOS(Group.getKey(), FileErr,
- llvm::sys::fs::OF_Text);
- if (FileErr) {
- return llvm::createStringError(FileErr, "Error opening file '%s'",
- Group.getKey().str().c_str());
- }
+ // Override the default HTML Mustache escape characters. We don't need to
+ // override `<` here.
+ static const DenseMap<char, std::string> EscapeChars;
+ RecordTemplate->setEscapeCharacters(EscapeChars);
+ NamespaceTemplate->setEscapeCharacters(EscapeChars);
+ AllFilesTemplate->setEscapeCharacters(EscapeChars);
+ IndexTemplate->setEscapeCharacters(EscapeChars);
- for (const auto &Info : Group.getValue()) {
- if (llvm::Error Err = generateDocForInfo(Info, InfoOS, CDCtx)) {
- return Err;
- }
- }
- }
+ return Error::success();
+}
- return llvm::Error::success();
+Error MDGenerator::generateDocumentation(
+ StringRef RootDir, StringMap<Info *> Infos,
+ const clang::doc::ClangDocContext &CDCtx, std::string Dirname) {
+ return MustacheGenerator::generateDocumentation(RootDir, std::move(Infos),
+ CDCtx, "md");
}
-llvm::Error MDGenerator::generateDocForInfo(Info *I, llvm::raw_ostream &OS,
- const ClangDocContext &CDCtx) {
- switch (I->IT) {
- case InfoType::IT_namespace:
- genMarkdown(CDCtx, *cast<NamespaceInfo>(I), OS);
- break;
- case InfoType::IT_record:
- genMarkdown(CDCtx, *cast<RecordInfo>(I), OS);
- break;
- case InfoType::IT_enum:
- genMarkdown(CDCtx, *cast<EnumInfo>(I), OS);
- break;
- case InfoType::IT_function:
- genMarkdown(CDCtx, *cast<FunctionInfo>(I), OS);
- break;
- case InfoType::IT_typedef:
- genMarkdown(CDCtx, *cast<TypedefInfo>(I), OS);
- break;
- case InfoType::IT_concept:
- case InfoType::IT_variable:
- case InfoType::IT_friend:
- break;
- case InfoType::IT_default:
- return createStringError(llvm::inconvertibleErrorCode(),
- "unexpected InfoType");
+Error MDGenerator::generateDocForJSON(json::Value &JSON, raw_fd_ostream &OS,
+ const ClangDocContext &CDCtx,
+ StringRef ObjTypeStr,
+ StringRef RelativeRootPath) {
+ if (ObjTypeStr == "record") {
+ assert(RecordTemplate && "RecordTemplate is nullptr.");
+ RecordTemplate->render(JSON, OS);
+ } else if (ObjTypeStr == "namespace") {
+ assert(NamespaceTemplate && "NamespaceTemplate is nullptr.");
+ NamespaceTemplate->render(JSON, OS);
+ } else if (ObjTypeStr == "all_files") {
+ assert(AllFilesTemplate && "AllFilesTemplate is nullptr.");
+ AllFilesTemplate->render(JSON, OS);
+ } else if (ObjTypeStr == "index") {
+ assert(IndexTemplate && "IndexTemplate is nullptr");
+ IndexTemplate->render(JSON, OS);
}
- return llvm::Error::success();
+ return Error::success();
}
-llvm::Error MDGenerator::createResources(ClangDocContext &CDCtx) {
- // Write an all_files.md
- auto Err = serializeIndex(CDCtx);
- if (Err)
- return Err;
-
- // Generate the index page.
- Err = genIndex(CDCtx);
- if (Err)
- return Err;
-
- return llvm::Error::success();
+Error MDGenerator::generateDocForInfo(Info *I, raw_ostream &OS,
+ const ClangDocContext &CDCtx) {
+ return Error::success();
}
+const char *MDGenerator::Format = "md";
+
static GeneratorRegistry::Add<MDGenerator> MD(MDGenerator::Format,
- "Generator for MD output.");
+ "Generator for Markdown output.");
namespace clang {
namespace doc {
-
-// This anchor is used to force the linker to link in the generated object
-// file and thus register the generator.
volatile int MDGeneratorAnchorSource = 0;
-
} // namespace doc
} // namespace clang
diff --git a/clang-tools-extra/clang-doc/MDMustacheGenerator.cpp b/clang-tools-extra/clang-doc/MDMustacheGenerator.cpp
deleted file mode 100644
index d2fd065a9453f..0000000000000
--- a/clang-tools-extra/clang-doc/MDMustacheGenerator.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// This file contains the implementation of the MDMustacheGenerator, which
-/// generates documentation in Markdown format using Mustache templates. It
-/// defines how the structured data in Info objects is mapped to template
-/// tags to produce readable markdown documents.
-///
-//===----------------------------------------------------------------------===//
-
-#include "Generators.h"
-
-using namespace llvm;
-using namespace clang::doc;
-
-static std::unique_ptr<MustacheTemplateFile> RecordTemplate = nullptr;
-
-static std::unique_ptr<MustacheTemplateFile> NamespaceTemplate = nullptr;
-
-static std::unique_ptr<MustacheTemplateFile> AllFilesTemplate = nullptr;
-
-static std::unique_ptr<MustacheTemplateFile> IndexTemplate = nullptr;
-
-namespace {
-struct MDMustacheGenerator : public MustacheGenerator {
- static const char *Format;
- Error generateDocumentation(StringRef RootDir, StringMap<Info *> Infos,
- const ClangDocContext &CDCtx,
- std::string DirName) override;
- Error setupTemplateFiles(const ClangDocContext &CDCtx) override;
- Error generateDocForJSON(json::Value &JSON, raw_fd_ostream &OS,
- const ClangDocContext &CDCtx,
- StringRef ObjectTypeStr,
- StringRef RelativeRootPath) override;
- // This generator doesn't need this function, but it inherits from the
- // original generator interface.
- Error generateDocForInfo(Info *I, llvm::raw_ostream &OS,
- const ClangDocContext &CDCtx) override;
-};
-} // namespace
-
-Error MDMustacheGenerator::setupTemplateFiles(const ClangDocContext &CDCtx) {
- std::string ClassFilePath = CDCtx.MustacheTemplates.lookup("class-template");
- std::string NamespaceFilePath =
- CDCtx.MustacheTemplates.lookup("namespace-template");
- std::string AllFilesPath = CDCtx.MustacheTemplates.lookup("all-files");
- std::string IndexFilePath = CDCtx.MustacheTemplates.lookup("index");
- std::string CommentsFilePath = CDCtx.MustacheTemplates.lookup("comments");
- std::vector<std::pair<StringRef, StringRef>> Partials = {
- {"Comments", CommentsFilePath}};
-
- if (Error Err = setupTemplate(RecordTemplate, ClassFilePath, Partials))
- return Err;
- if (Error Err = setupTemplate(NamespaceTemplate, NamespaceFilePath, Partials))
- return Err;
- if (Error Err = setupTemplate(AllFilesTemplate, AllFilesPath, Partials))
- return Err;
- if (Error Err = setupTemplate(IndexTemplate, IndexFilePath, Partials))
- return Err;
-
- // Override the default HTML Mustache escape characters. We don't need to
- // override `<` here.
- static const DenseMap<char, std::string> EscapeChars;
- RecordTemplate->setEscapeCharacters(EscapeChars);
- NamespaceTemplate->setEscapeCharacters(EscapeChars);
- AllFilesTemplate->setEscapeCharacters(EscapeChars);
- IndexTemplate->setEscapeCharacters(EscapeChars);
-
- return Error::success();
-}
-
-Error MDMustacheGenerator::generateDocumentation(
- StringRef RootDir, StringMap<Info *> Infos,
- const clang::doc::ClangDocContext &CDCtx, std::string Dirname) {
- return MustacheGenerator::generateDocumentation(RootDir, std::move(Infos),
- CDCtx, "md");
-}
-
-Error MDMustacheGenerator::generateDocForJSON(json::Value &JSON,
- raw_fd_ostream &OS,
- const ClangDocContext &CDCtx,
- StringRef ObjTypeStr,
- StringRef RelativeRootPath) {
- if (ObjTypeStr == "record") {
- assert(RecordTemplate && "RecordTemplate is nullptr.");
- RecordTemplate->render(JSON, OS);
- } else if (ObjTypeStr == "namespace") {
- assert(NamespaceTemplate && "NamespaceTemplate is nullptr.");
- NamespaceTemplate->render(JSON, OS);
- } else if (ObjTypeStr == "all_files") {
- assert(AllFilesTemplate && "AllFilesTemplate is nullptr.");
- AllFilesTemplate->render(JSON, OS);
- } else if (ObjTypeStr == "index") {
- assert(IndexTemplate && "IndexTemplate is nullptr");
- IndexTemplate->render(JSON, OS);
- }
- return Error::success();
-}
-
-Error MDMustacheGenerator::generateDocForInfo(Info *I, raw_ostream &OS,
- const ClangDocContext &CDCtx) {
- return Error::success();
-}
-
-const char *MDMustacheGenerator::Format = "md_mustache";
-
-static GeneratorRegistry::Add<MDMustacheGenerator>
- MDMustache(MDMustacheGenerator::Format,
- "Generator for mustache Markdown output.");
-
-namespace clang {
-namespace doc {
-volatile int MDMustacheGeneratorAnchorSource = 0;
-} // namespace doc
-} // namespace clang
diff --git a/clang-tools-extra/clang-doc/Representation.h b/clang-tools-extra/clang-doc/Representation.h
index e3ad7fa3f375d..3a7a6deb3d0a3 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -225,7 +225,7 @@ enum class CommentKind {
CK_Unknown
};
-enum OutputFormatTy { md, yaml, html, json, md_mustache };
+enum OutputFormatTy { md, yaml, html, json };
CommentKind stringToCommentKind(llvm::StringRef KindStr);
llvm::StringRef commentKindToString(CommentKind Kind);
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 38002f5111a9f..c3e61e26612aa 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -117,19 +117,18 @@ static llvm::cl::opt<bool>
Pretty("pretty-json", llvm::cl::desc("Serialize JSON with whitespace."),
llvm::cl::cat(ClangDocCategory));
-static llvm::cl::opt<OutputFormatTy> FormatEnum(
- "format", llvm::cl::desc("Format for outputted docs."),
- llvm::cl::values(clEnumValN(OutputFormatTy::yaml, "yaml",
- "Documentation in YAML format."),
- clEnumValN(OutputFormatTy::md, "md",
- "Documentation in MD format."),
- clEnumValN(OutputFormatTy::html, "html",
- "Documentation in HTML format."),
- clEnumValN(OutputFormatTy::json, "json",
- "Documentation in JSON format"),
- clEnumValN(OutputFormatTy::md_mustache, "md_mustache",
- "Documentation in MD format.")),
- llvm::cl::init(OutputFormatTy::yaml), llvm::cl::cat(ClangDocCategory));
+static llvm::cl::opt<OutputFormatTy>
+ FormatEnum("format", llvm::cl::desc("Format for outputted docs."),
+ llvm::cl::values(clEnumValN(OutputFormatTy::yaml, "yaml",
+ "Documentation in YAML format."),
+ clEnumValN(OutputFormatTy::md, "md",
+ "Documentation in MD format."),
+ clEnumValN(OutputFormatTy::html, "html",
+ "Documentation in HTML format."),
+ clEnumValN(OutputFormatTy::json, "json",
+ "Documentation in JSON format")),
+ llvm::cl::init(OutputFormatTy::yaml),
+ llvm::cl::cat(ClangDocCategory));
static llvm::ExitOnError ExitOnErr;
@@ -143,8 +142,6 @@ static llvm::StringRef getFormatString() {
return "html";
case OutputFormatTy::json:
return "json";
- case OutputFormatTy::md_mustache:
- return "md_mustache";
}
llvm_unreachable("Unknown OutputFormatTy");
}
@@ -313,7 +310,7 @@ Example usage for a project using a compile commands database:
if (Format == "html")
ExitOnErr(getHtmlFiles(argv[0], CDCtx));
- else if (Format == "md_mustache")
+ else if (Format == "md")
ExitOnErr(getMdFiles(argv[0], CDCtx));
llvm::timeTraceProfilerBegin("Executor Launch", "total runtime");
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 543a6111bea77..d97f526f06efb 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.mustache.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.mustache.test
@@ -7,7 +7,7 @@
// RUN: FileCheck %s -input-file=%t/docs/html/GlobalNamespace/_ZTV9Rectangle.html -check-prefix=HTML-RECTANGLE
// RUN: FileCheck %s -input-file=%t/docs/html/GlobalNamespace/_ZTV6Circle.html -check-prefix=HTML-CIRCLE
-// RUN: clang-doc --format=md_mustache --output=%t/docs --executor=all-TUs %t/build/compile_commands.json
+// RUN: clang-doc --format=md --output=%t/docs --executor=all-TUs %t/build/compile_commands.json
// RUN: FileCheck %s -input-file=%t/docs/md/all_files.md -check-prefixes=MD-ALL-FILES
// RUN: FileCheck %s -input-file=%t/docs/md/index.md -check-prefixes=MD-INDEX
// RUN: FileCheck %s -input-file=%t/docs/md/GlobalNamespace/_ZTV5Shape.md -check-prefixes=MD-SHAPE
diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test
index bd895f3f0ade8..c71565fa24d60 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,13 +1,7 @@
// RUN: rm -rf %t && mkdir -p %t/docs %t/build
// RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json > %t/build/compile_commands.json
-// RUN: clang-doc --format=md --output=%t/docs --executor=all-TUs %t/build/compile_commands.json
-// RUN: FileCheck %s -input-file=%t/docs/all_files.md -check-prefixes=MD-ALL-FILES
-// RUN: FileCheck %s -input-file=%t/docs/index.md -check-prefixes=MD-INDEX
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Shape.md -check-prefixes=MD-SHAPE
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Calculator.md -check-prefixes=MD-CALC
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Rectangle.md -check-prefixes=MD-RECTANGLE
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/Circle.md -check-prefixes=MD-CIRCLE
+// RUN: clang-doc --format=json --output=%t/docs --executor=all-TUs %t/build/compile_commands.json
// JSON-INDEX: async function LoadIndex() {
// JSON-INDEX-NEXT: return{
@@ -55,122 +49,3 @@
// JSON-INDEX-NEXT: ]
// JSON-INDEX-NEXT: };
// JSON-INDEX-NEXT: }
-
-// MD-CALC: # class Calculator
-// MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
-// MD-CALC: **brief** A simple calculator class.
-// MD-CALC: Provides basic arithmetic operations.
-// MD-CALC: ## Members
-// MD-CALC: public int public_val
-// MD-CALC: public static const int static_val
-// MD-CALC: ## Functions
-// MD-CALC: ### add
-// MD-CALC: *public int add(int a, int b)*
-// MD-CALC: *Defined at .{{[\/]}}src{{[\/]}}Calculator.cpp#3*
-// MD-CALC: **brief** Adds two integers.
-// MD-CALC: **a** First integer.
-// MD-CALC: **b** Second integer.
-// MD-CALC: **return** int The sum of a and b.
-// MD-CALC: ### subtract
-// MD-CALC: *public int subtract(int a, int b)*
-// MD-CALC: *Defined at .{{[\/]}}src{{[\/]}}Calculator.cpp#5*
-// MD-CALC: **brief** Subtracts the second integer from the first.
-// MD-CALC: **a** First integer.
-// MD-CALC: **b** Second integer.
-// MD-CALC: **return** int The result of a - b.
-// MD-CALC: ### multiply
-// MD-CALC: *public int multiply(int a, int b)*
-// MD-CALC: *Defined at .{{[\/]}}src{{[\/]}}Calculator.cpp#7*
-// MD-CALC: **brief** Multiplies two integers.
-// MD-CALC: **a** First integer.
-// MD-CALC: **b** Second integer.
-// MD-CALC: **return** int The product of a and b.
-// MD-CALC: ### divide
-// MD-CALC: *public double divide(int a, int b)*
-// MD-CALC: *Defined at .{{[\/]}}src{{[\/]}}Calculator.cpp#9*
-// MD-CALC: **brief** Divides the first integer by the second.
-// MD-CALC: **a** First integer.
-// MD-CALC: **b** Second integer.
-// MD-CALC: **return** double The result of a / b.
-// MD-CALC: **throw** if b is zero.
-// MD-CALC: ### mod
-// MD-CALC: *public static int mod(int a, int b)*
-// MD-CALC: *Defined at ./include{{[\/]}}Calculator.h#54*
-// MD-CALC: **brief** Performs the mod operation on integers.
-// MD-CALC: **a** First integer.
-// MD-CALC: **b** Second integer.
-// MD-CALC: **return** The result of a % b.
-
-// MD-CIRCLE: # class Circle
-// MD-CIRCLE: *Defined at .{{[\/]}}include{{[\/]}}Circle.h#10*
-// MD-CIRCLE: **brief** Circle class derived from Shape.
-// MD-CIRCLE: Represents a circle with a given radius.
-// MD-CIRCLE: Inherits from Shape
-// MD-CIRCLE: ## Members
-// MD-CIRCLE: private double radius_
-// MD-CIRCLE: ## Functions
-// MD-CIRCLE: ### Circle
-// MD-CIRCLE: *public void Circle(double radius)*
-// MD-CIRCLE: *Defined at .{{[\/]}}src{{[\/]}}Circle.cpp#3*
-// MD-CIRCLE: **brief** Constructs a new Circle object.
-// MD-CIRCLE: **radius** Radius of the circle.
-// MD-CIRCLE: ### area
-// MD-CIRCLE: *public double area()*
-// MD-CIRCLE: *Defined at .{{[\/]}}src{{[\/]}}Circle.cpp#5*
-// MD-CIRCLE: **brief** Calculates the area of the circle.
-// MD-CIRCLE: **return** double The area of the circle.
-// MD-CIRCLE: ### perimeter
-// MD-CIRCLE: *public double perimeter()*
-// MD-CIRCLE: *Defined at .{{[\/]}}src{{[\/]}}Circle.cpp#7*
-// MD-CIRCLE: **brief** Calculates the perimeter of the circle.
-// MD-CIRCLE: **return** double The perimeter of the circle.
-
-// MD-RECTANGLE: # class Rectangle
-// MD-RECTANGLE: *Defined at .{{[\/]}}include{{[\/]}}Rectangle.h#10*
-// MD-RECTANGLE: **brief** Rectangle class derived from Shape.
-// MD-RECTANGLE: Represents a rectangle with a given width and height.
-// MD-RECTANGLE: Inherits from Shape
-// MD-RECTANGLE: ## Members
-// MD-RECTANGLE: private double width_
-// MD-RECTANGLE: private double height_
-// MD-RECTANGLE: ## Functions
-// MD-RECTANGLE: ### Rectangle
-// MD-RECTANGLE: *public void Rectangle(double width, double height)*
-// MD-RECTANGLE: *Defined at .{{[\/]}}src{{[\/]}}Rectangle.cpp#3*
-// MD-RECTANGLE: **brief** Constructs a new Rectangle object.
-// MD-RECTANGLE: **width** Width of the rectangle.
-// MD-RECTANGLE: **height** Height of the rectangle.
-// MD-RECTANGLE: ### area
-// MD-RECTANGLE: *public double area()*
-// MD-RECTANGLE: *Defined at .{{[\/]}}src{{[\/]}}Rectangle.cpp#6*
-// MD-RECTANGLE: **brief** Calculates the area of the rectangle.
-// MD-RECTANGLE: **return** double The area of the rectangle.
-// MD-RECTANGLE: ### perimeter
-// MD-RECTANGLE: *public double perimeter()*
-// MD-RECTANGLE: *Defined at .{{[\/]}}src{{[\/]}}Rectangle.cpp#8*
-// MD-RECTANGLE: **brief** Calculates the perimeter of the rectangle.
-// MD-RECTANGLE: **return** double The perimeter of the rectangle.
-
-// MD-SHAPE: # class Shape
-// MD-SHAPE: *Defined at .{{[\/]}}include{{[\/]}}Shape.h#8*
-// MD-SHAPE: **brief** Abstract base class for shapes.
-// MD-SHAPE: Provides a common interface for different types of shapes.
-// MD-SHAPE: ## Functions
-// MD-SHAPE: ### area
-// MD-SHAPE: *public double area()*
-// MD-SHAPE: **brief** Calculates the area of the shape.
-// MD-SHAPE: **return** double The area of the shape.
-// MD-SHAPE: ### perimeter
-// MD-SHAPE: *public double perimeter()*
-// MD-SHAPE: **brief** Calculates the perimeter of the shape.
-// MD-SHAPE: **return** double The perimeter of the shape.
-// MD-SHAPE: ### ~Shape
-// MD-SHAPE: *public void ~Shape()*
-// MD-SHAPE: *Defined at .{{[\/]}}include{{[\/]}}Shape.h#13*
-// MD-SHAPE: **brief** Virtual destructor.
-
-// MD-ALL-FILES: # All Files
-// MD-ALL-FILES: ## [GlobalNamespace](GlobalNamespace{{[\/]}}index.md)
-
-// MD-INDEX: # C/C++ Reference
-// MD-INDEX: * Namespace: [GlobalNamespace](GlobalNamespace)
diff --git a/clang-tools-extra/test/clang-doc/md/array-type.cpp b/clang-tools-extra/test/clang-doc/md/array-type.cpp
index 3fda12a9d6015..a70d464c38ec2 100644
--- a/clang-tools-extra/test/clang-doc/md/array-type.cpp
+++ b/clang-tools-extra/test/clang-doc/md/array-type.cpp
@@ -1,8 +1,5 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --output=%t --format=md --executor=standalone %S/../Inputs/array-type.cpp
-// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/index.md
-// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone %S/../Inputs/array-type.cpp
-// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < %t/md/GlobalNamespace/index.md
+// RUN: FileCheck %s --check-prefix=MD < %t/md/GlobalNamespace/index.md
// MD: *void qux(int (&)[5] arr)*
-// MD-MUSTACHE: *void qux(int (&)[5] arr)*
diff --git a/clang-tools-extra/test/clang-doc/md/builtin_types.cpp b/clang-tools-extra/test/clang-doc/md/builtin_types.cpp
index 45c690acc7d86..973a49f1353f8 100644
--- a/clang-tools-extra/test/clang-doc/md/builtin_types.cpp
+++ b/clang-tools-extra/test/clang-doc/md/builtin_types.cpp
@@ -1,60 +1,30 @@
-// RUN: rm -rf %t
-// RUN: mkdir -p %t/yaml %t/md %t/md_mustache
-// RUN: clang-doc --doxygen --executor=standalone %S/../Inputs/builtin_types.cpp -output=%t/md --format=md
-// RUN: FileCheck %s < %t/md/GlobalNamespace/index.md --check-prefix=MD
-// RUN: clang-doc --doxygen --executor=standalone %S/../Inputs/builtin_types.cpp -output=%t/md_mustache --format=md_mustache
-// RUN: FileCheck %s < %t/md_mustache/md/GlobalNamespace/index.md --check-prefix=MD-MUSTACHE
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --doxygen --executor=standalone %S/../Inputs/builtin_types.cpp --output=%t --format=md
+// RUN: FileCheck %s < %t/md/GlobalNamespace/index.md --check-prefix=MD
// MD: # Global Namespace
// MD: ## Functions
-// MD-MUSTACHE: # Global Namespace
-// MD-MUSTACHE: ## Functions
-
// MD: ### b
// MD: *bool b()*
-// MD-MUSTACHE: ### b
-// MD-MUSTACHE: *bool b()*
-
// MD: ### c
// MD: *char c()*
-// MD-MUSTACHE: ### c
-// MD-MUSTACHE: *char c()*
-
// MD: ### d
// MD: *double d()*
-// MD-MUSTACHE: ### d
-// MD-MUSTACHE: *double d()*
-
// MD: ### f
// MD: *float f()*
-// MD-MUSTACHE: ### f
-// MD-MUSTACHE: *float f()*
-
// MD: ### i
// MD: *int i()*
-// MD-MUSTACHE: ### i
-// MD-MUSTACHE: *int i()*
-
// MD: ### l
// MD: *long l()*
-// MD-MUSTACHE: ### l
-// MD-MUSTACHE: *long l()*
-
// MD: ### ll
// MD: *long long ll()*
-// MD-MUSTACHE: ### ll
-// MD-MUSTACHE: *long long ll()*
-
// MD: ### s
// MD: *short s()*
-
-// MD-MUSTACHE: ### s
-// MD-MUSTACHE: *short s()*
diff --git a/clang-tools-extra/test/clang-doc/md/class-partial-specialization.cpp b/clang-tools-extra/test/clang-doc/md/class-partial-specialization.cpp
index 01ebca3f3064a..bdddca8045802 100644
--- a/clang-tools-extra/test/clang-doc/md/class-partial-specialization.cpp
+++ b/clang-tools-extra/test/clang-doc/md/class-partial-specialization.cpp
@@ -1,8 +1,5 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --output=%t --format=md --executor=standalone %S/../Inputs/class-partial-specialization.cpp
-// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/MyClass.md
-// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone %S/../Inputs/class-partial-specialization.cpp
-// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < %t/md/GlobalNamespace/_ZTV7MyClassIPT_E.md
+// RUN: FileCheck %s --check-prefix=MD < %t/md/GlobalNamespace/_ZTV7MyClassIPT_E.md
// MD: # struct MyClass
-// MD-MUSTACHE: # struct MyClass
diff --git a/clang-tools-extra/test/clang-doc/md/comments-in-macros.cpp b/clang-tools-extra/test/clang-doc/md/comments-in-macros.cpp
index d544dff7c361a..33cb71627da42 100644
--- a/clang-tools-extra/test/clang-doc/md/comments-in-macros.cpp
+++ b/clang-tools-extra/test/clang-doc/md/comments-in-macros.cpp
@@ -1,18 +1,11 @@
// RUN: rm -rf %t && mkdir -p %t
-// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %S/../Inputs/comments-in-macros.cpp
-// RUN: clang-doc --format=md_mustache --doxygen --output=%t --executor=standalone %S/../Inputs/comments-in-macros.cpp
-// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS-LINE
-// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS
-// RUN: FileCheck %s < %t/md/GlobalNamespace/_ZTV7MyClass.md --check-prefix=MD-MUSTACHE-MYCLASS-LINE
-// RUN: FileCheck %s < %t/md/GlobalNamespace/_ZTV7MyClass.md --check-prefix=MD-MUSTACHE-MYCLASS
+// RUN: clang-doc --format=md -doxygen --output=%t --executor=standalone %S/../Inputs/comments-in-macros.cpp
+// RUN: FileCheck %s < %t/md/GlobalNamespace/_ZTV7MyClass.md --check-prefix=MD-MYCLASS-LINE
+// RUN: FileCheck %s < %t/md/GlobalNamespace/_ZTV7MyClass.md --check-prefix=MD-MYCLASS
+
// MD-MYCLASS: ### Add
// MD-MYCLASS: *public int Add(int a, int b)*
// MD-MYCLASS: **brief** Declare a method to calculate the sum of two numbers
-// MD-MUSTACHE-MYCLASS: ### Add
-// MD-MUSTACHE-MYCLASS: *public int Add(int a, int b)*
-// MD-MUSTACHE-MYCLASS: **brief** Declare a method to calculate the sum of two numbers
-
// MD-MYCLASS-LINE: *Defined at {{.*}}comments-in-macros.cpp#7*
-// MD-MUSTACHE-MYCLASS-LINE: *Defined at {{.*}}comments-in-macros.cpp#7*
diff --git a/clang-tools-extra/test/clang-doc/md/enum.cpp b/clang-tools-extra/test/clang-doc/md/enum.cpp
index f2ad31755173e..1550e66ff1c96 100644
--- a/clang-tools-extra/test/clang-doc/md/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/md/enum.cpp
@@ -1,110 +1,38 @@
// RUN: rm -rf %t && mkdir -p %t
-// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %S/../Inputs/enum.cpp
-// RUN: clang-doc --format=md_mustache --pretty-json --doxygen --output=%t --executor=standalone %S/../Inputs/enum.cpp
-// RUN: FileCheck %s < %t/GlobalNamespace/index.md --check-prefix=MD-INDEX
-// RUN: FileCheck %s < %t/GlobalNamespace/Animals.md --check-prefix=MD-ANIMAL
-// RUN: FileCheck %s < %t/GlobalNamespace/FilePermissions.md --check-prefix=MD-PERM
-// RUN: FileCheck %s < %t/Vehicles/index.md --check-prefix=MD-VEHICLES
-// RUN: FileCheck %s < %t/md/GlobalNamespace/index.md --check-prefix=MD-MUSTACHE-INDEX
-// RUN: FileCheck %s < %t/md/GlobalNamespace/_ZTV7Animals.md --check-prefix=MD-MUSTACHE-ANIMAL
-// RUN: FileCheck %s < %t/md/Vehicles/index.md --check-prefix=MD-MUSTACHE-VEHICLES
+// RUN: clang-doc --format=md --pretty-json --doxygen --output=%t --executor=standalone %S/../Inputs/enum.cpp
+// RUN: FileCheck %s < %t/md/GlobalNamespace/index.md --check-prefix=MD-INDEX
+// RUN: FileCheck %s < %t/md/GlobalNamespace/_ZTV7Animals.md --check-prefix=MD-ANIMAL
+// RUN: FileCheck %s < %t/md/Vehicles/index.md --check-prefix=MD-VEHICLES
// MD-INDEX: ## Enums
// MD-INDEX: | enum Color |
-// MD-INDEX: | Name | Value | Comments |
-// MD-INDEX: |---|---|---|
-// MD-INDEX: | Red | 0 | Comment 1 |
-// MD-INDEX: | Green | 1 | Comment 2 |
-// MD-INDEX: | Blue | 2 | Comment 3 |
+// MD-INDEX: --
+// MD-INDEX: | Red |
+// MD-INDEX: | Green |
+// MD-INDEX: | Blue |
// MD-INDEX: **brief** For specifying RGB colors
-// MD-MUSTACHE-INDEX: ## Enums
-// MD-MUSTACHE-INDEX: | enum Color |
-// MD-MUSTACHE-INDEX: --
-// MD-MUSTACHE-INDEX: | Red |
-// MD-MUSTACHE-INDEX: | Green |
-// MD-MUSTACHE-INDEX: | Blue |
-// MD-MUSTACHE-INDEX: **brief** For specifying RGB colors
-
-// MD-INDEX: | enum class Shapes |
-// MD-INDEX: | Name | Value | Comments |
-// MD-INDEX: |---|---|---|
-// MD-INDEX: | Circle | 0 | Comment 1 |
-// MD-INDEX: | Rectangle | 1 | Comment 2 |
-// MD-INDEX: | Triangle | 2 | Comment 3 |
-// MD-INDEX: **brief** Shape Types
-
-// MD-INDEX: | enum Size : uint8_t |
-// MD-INDEX: | Name | Value | Comments |
-// MD-INDEX: |---|---|---|
-// MD-INDEX: | Small | 0 | A pearl.<br>Pearls are quite small.<br><br>Pearls are used in jewelry. |
-// MD-INDEX: | Medium | 1 | A tennis ball. |
-// MD-INDEX: | Large | 2 | A football. |
-// MD-INDEX: **brief** Specify the size
-
-// MD-INDEX: | enum (unnamed) : long long |
-// MD-INDEX: | Name | Value | Comments |
-// MD-INDEX: |---|---|---|
-// MD-INDEX: | BigVal | 999999999999 | A very large value |
-// MD-INDEX: **brief** Very long number
-
// MD-INDEX: | enum ColorUserSpecified |
-// MD-INDEX: | Name | Value |
-// MD-INDEX: |---|---|
-// MD-INDEX: | RedUserSpecified | 65 |
-// MD-INDEX: | GreenUserSpecified | 2 |
-// MD-INDEX: | BlueUserSpecified | 67 |
-
-// MD-MUSTACHE-INDEX: | enum ColorUserSpecified |
-// MD-MUSTACHE-INDEX: --
-// MD-MUSTACHE-INDEX: | RedUserSpecified |
-// MD-MUSTACHE-INDEX: | GreenUserSpecified |
-// MD-MUSTACHE-INDEX: | BlueUserSpecified |
-
-// MD-PERM: | enum (unnamed) |
-// MD-PERM: | Name | Value | Comments |
-// MD-PERM: |---|---|---|
-// MD-PERM: | Read | 1 | Permission to READ r |
-// MD-PERM: | Write | 2 | Permission to WRITE w |
-// MD-PERM: | Execute | 4 | Permission to EXECUTE x |
-// MD-PERM: **brief** File permission flags
+// MD-INDEX: --
+// MD-INDEX: | RedUserSpecified |
+// MD-INDEX: | GreenUserSpecified |
+// MD-INDEX: | BlueUserSpecified |
// MD-ANIMAL: # class Animals
// MD-ANIMAL: ## Enums
// MD-ANIMAL: | enum AnimalType |
-// MD-ANIMAL: | Name | Value | Comments |
-// MD-ANIMAL: |---|---|---|
-// MD-ANIMAL: | Dog | 0 | Man's best friend |
-// MD-ANIMAL: | Cat | 1 | Man's other best friend |
-// MD-ANIMAL: | Iguana | 2 | A lizard |
+// MD-ANIMAL: --
+// MD-ANIMAL: | Dog |
+// MD-ANIMAL: | Cat |
+// MD-ANIMAL: | Iguana |
// MD-ANIMAL: **brief** specify what animal the class is
-// MD-MUSTACHE-ANIMAL: # class Animals
-// MD-MUSTACHE-ANIMAL: ## Enums
-// MD-MUSTACHE-ANIMAL: | enum AnimalType |
-// MD-MUSTACHE-ANIMAL: --
-// MD-MUSTACHE-ANIMAL: | Dog |
-// MD-MUSTACHE-ANIMAL: | Cat |
-// MD-MUSTACHE-ANIMAL: | Iguana |
-// MD-MUSTACHE-ANIMAL: **brief** specify what animal the class is
-
// MD-VEHICLES: # namespace Vehicles
// MD-VEHICLES: ## Enums
// MD-VEHICLES: | enum Car |
-// MD-VEHICLES: | Name | Value | Comments |
-// MD-VEHICLES: |---|---|---|
-// MD-VEHICLES: | Sedan | 0 | Comment 1 |
-// MD-VEHICLES: | SUV | 1 | Comment 2 |
-// MD-VEHICLES: | Pickup | 2 | -- |
-// MD-VEHICLES: | Hatchback | 3 | Comment 4 |
+// MD-VEHICLES: --
+// MD-VEHICLES: | Sedan |
+// MD-VEHICLES: | SUV |
+// MD-VEHICLES: | Pickup |
+// MD-VEHICLES: | Hatchback |
// MD-VEHICLES: **brief** specify type of car
-
-// MD-MUSTACHE-VEHICLES: # namespace Vehicles
-// MD-MUSTACHE-VEHICLES: ## Enums
-// MD-MUSTACHE-VEHICLES: | enum Car |
-// MD-MUSTACHE-VEHICLES: --
-// MD-MUSTACHE-VEHICLES: | Sedan |
-// MD-MUSTACHE-VEHICLES: | SUV |
-// MD-MUSTACHE-VEHICLES: | Pickup |
-// MD-MUSTACHE-VEHICLES: | Hatchback |
-// MD-MUSTACHE-VEHICLES: **brief** specify type of car
diff --git a/clang-tools-extra/test/clang-doc/md/function-pointer-type.cpp b/clang-tools-extra/test/clang-doc/md/function-pointer-type.cpp
index 2983adb00893f..de1f60c3d9b85 100644
--- a/clang-tools-extra/test/clang-doc/md/function-pointer-type.cpp
+++ b/clang-tools-extra/test/clang-doc/md/function-pointer-type.cpp
@@ -1,8 +1,5 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --output=%t --format=md --executor=standalone %S/../Inputs/function-pointer-type.cpp
-// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/index.md
-// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone %S/../Inputs/function-pointer-type.cpp
-// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < %t/md/GlobalNamespace/index.md
+// RUN: FileCheck %s --check-prefix=MD < %t/md/GlobalNamespace/index.md
// MD: *void bar(void (*)(int) fn)*
-// MD-MUSTACHE: *void bar(void (*)(int) fn)*
diff --git a/clang-tools-extra/test/clang-doc/md/member-function-pointer-type.cpp b/clang-tools-extra/test/clang-doc/md/member-function-pointer-type.cpp
index a84467f8d9c2c..588b9beeecc99 100644
--- a/clang-tools-extra/test/clang-doc/md/member-function-pointer-type.cpp
+++ b/clang-tools-extra/test/clang-doc/md/member-function-pointer-type.cpp
@@ -1,8 +1,5 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --output=%t --format=md --executor=standalone %S/../Inputs/member-function-pointer-type.cpp
-// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/index.md
-// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone %S/../Inputs/member-function-pointer-type.cpp
-// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < %t/md/GlobalNamespace/index.md
+// RUN: FileCheck %s --check-prefix=MD < %t/md/GlobalNamespace/index.md
// MD: *void baz(void (Class::*)(int) fn)*
-// MD-MUSTACHE: *void baz(void (Class::*)(int) fn)*
diff --git a/clang-tools-extra/test/clang-doc/md/namespace.cpp b/clang-tools-extra/test/clang-doc/md/namespace.cpp
index 8a89eda6a6d50..a9dd6880290f6 100644
--- a/clang-tools-extra/test/clang-doc/md/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/md/namespace.cpp
@@ -1,94 +1,53 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --format=md --output=%t --executor=standalone %S/../Inputs/namespace-html-md.cpp
-// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.md -check-prefix=MD-ANON-CLASS-LINE
-// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.md -check-prefix=MD-ANON-CLASS
-// RUN: FileCheck %s < %t/@nonymous_namespace/index.md -check-prefix=MD-ANON-INDEX-LINE
-// RUN: FileCheck %s < %t/@nonymous_namespace/index.md -check-prefix=MD-ANON-INDEX
-// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.md -check-prefix=MD-ANOTHER-CLASS-LINE
-// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.md -check-prefix=MD-ANOTHER-CLASS
-// RUN: FileCheck %s < %t/AnotherNamespace/index.md -check-prefix=MD-ANOTHER-INDEX-LINE
-// RUN: FileCheck %s < %t/AnotherNamespace/index.md -check-prefix=MD-ANOTHER-INDEX
-// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.md -check-prefix=MD-NESTED-CLASS-LINE
-// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.md -check-prefix=MD-NESTED-CLASS
-// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-NESTED-INDEX-LINE
-// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-NESTED-INDEX
-// RUN: FileCheck %s < %t/PrimaryNamespace/index.md -check-prefix=MD-PRIMARY-INDEX-LINE
-// RUN: FileCheck %s < %t/PrimaryNamespace/index.md -check-prefix=MD-PRIMARY-INDEX
-// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.md -check-prefix=MD-PRIMARY-CLASS-LINE
-// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.md -check-prefix=MD-PRIMARY-CLASS
-// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-GLOBAL-INDEX
-// RUN: FileCheck %s < %t/all_files.md -check-prefix=MD-ALL-FILES
-// RUN: FileCheck %s < %t/index.md -check-prefix=MD-INDEX
-// RUN: clang-doc --format=md_mustache --output=%t --executor=standalone %S/../Inputs/namespace-html-md.cpp
-// RUN: FileCheck %s < %t/md/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.md -check-prefix=MD-MUSTACHE-ANON-CLASS-LINE
-// RUN: FileCheck %s < %t/md/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.md -check-prefix=MD-MUSTACHE-ANON-CLASS
-// RUN: FileCheck %s < %t/md/@nonymous_namespace/index.md -check-prefix=MD-MUSTACHE-ANON-INDEX-LINE
-// RUN: FileCheck %s < %t/md/@nonymous_namespace/index.md -check-prefix=MD-MUSTACHE-ANON-INDEX
-// RUN: FileCheck %s < %t/md/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.md -check-prefix=MD-MUSTACHE-ANOTHER-CLASS-LINE
-// RUN: FileCheck %s < %t/md/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.md -check-prefix=MD-MUSTACHE-ANOTHER-CLASS
-// RUN: FileCheck %s < %t/md/AnotherNamespace/index.md -check-prefix=MD-MUSTACHE-ANOTHER-INDEX-LINE
-// RUN: FileCheck %s < %t/md/AnotherNamespace/index.md -check-prefix=MD-MUSTACHE-ANOTHER-INDEX
-// RUN: FileCheck %s < %t/md/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.md -check-prefix=MD-MUSTACHE-NESTED-CLASS-LINE
-// RUN: FileCheck %s < %t/md/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.md -check-prefix=MD-MUSTACHE-NESTED-CLASS
-// RUN: FileCheck %s < %t/md/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-MUSTACHE-NESTED-INDEX-LINE
-// RUN: FileCheck %s < %t/md/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-MUSTACHE-NESTED-INDEX
-// RUN: FileCheck %s < %t/md/PrimaryNamespace/index.md -check-prefix=MD-MUSTACHE-PRIMARY-INDEX-LINE
-// RUN: FileCheck %s < %t/md/PrimaryNamespace/index.md -check-prefix=MD-MUSTACHE-PRIMARY-INDEX
-// RUN: FileCheck %s < %t/md/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.md -check-prefix=MD-MUSTACHE-PRIMARY-CLASS-LINE
-// RUN: FileCheck %s < %t/md/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.md -check-prefix=MD-MUSTACHE-PRIMARY-CLASS
-// RUN: FileCheck %s < %t/md/GlobalNamespace/index.md -check-prefix=MD-MUSTACHE-GLOBAL-INDEX
-// RUN: FileCheck %s < %t/md/all_files.md -check-prefix=MD-MUSTACHE-ALL-FILES
-// RUN: FileCheck %s < %t/md/index.md -check-prefix=MD-MUSTACHE-INDEX
+// RUN: FileCheck %s < %t/md/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.md -check-prefix=MD-ANON-CLASS-LINE
+// RUN: FileCheck %s < %t/md/@nonymous_namespace/_ZTVN12_GLOBAL__N_19AnonClassE.md -check-prefix=MD-ANON-CLASS
+// RUN: FileCheck %s < %t/md/@nonymous_namespace/index.md -check-prefix=MD-ANON-INDEX-LINE
+// RUN: FileCheck %s < %t/md/@nonymous_namespace/index.md -check-prefix=MD-ANON-INDEX
+// RUN: FileCheck %s < %t/md/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.md -check-prefix=MD-ANOTHER-CLASS-LINE
+// RUN: FileCheck %s < %t/md/AnotherNamespace/_ZTVN16AnotherNamespace23ClassInAnotherNamespaceE.md -check-prefix=MD-ANOTHER-CLASS
+// RUN: FileCheck %s < %t/md/AnotherNamespace/index.md -check-prefix=MD-ANOTHER-INDEX-LINE
+// RUN: FileCheck %s < %t/md/AnotherNamespace/index.md -check-prefix=MD-ANOTHER-INDEX
+// RUN: FileCheck %s < %t/md/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.md -check-prefix=MD-NESTED-CLASS-LINE
+// RUN: FileCheck %s < %t/md/PrimaryNamespace/NestedNamespace/_ZTVN16PrimaryNamespace15NestedNamespace22ClassInNestedNamespaceE.md -check-prefix=MD-NESTED-CLASS
+// RUN: FileCheck %s < %t/md/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-NESTED-INDEX-LINE
+// RUN: FileCheck %s < %t/md/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-NESTED-INDEX
+// RUN: FileCheck %s < %t/md/PrimaryNamespace/index.md -check-prefix=MD-PRIMARY-INDEX-LINE
+// RUN: FileCheck %s < %t/md/PrimaryNamespace/index.md -check-prefix=MD-PRIMARY-INDEX
+// RUN: FileCheck %s < %t/md/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.md -check-prefix=MD-PRIMARY-CLASS-LINE
+// RUN: FileCheck %s < %t/md/PrimaryNamespace/_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.md -check-prefix=MD-PRIMARY-CLASS
+// RUN: FileCheck %s < %t/md/GlobalNamespace/index.md -check-prefix=MD-GLOBAL-INDEX
+// RUN: FileCheck %s < %t/md/all_files.md -check-prefix=MD-ALL-FILES
+// RUN: FileCheck %s < %t/md/index.md -check-prefix=MD-INDEX
// MD-ANON-INDEX-LINE: *Defined at {{.*}}namespace-html-md.cpp#3*
-// MD-MUSTACHE-ANON-INDEX-LINE: *Defined at {{.*}}namespace-html-md.cpp#3*
// MD-ANON-CLASS-LINE: *Defined at {{.*}}namespace-html-md.cpp#4*
-// MD-MUSTACHE-ANON-CLASS-LINE: *Defined at {{.*}}namespace-html-md.cpp#4*
// MD-ANON-CLASS: # class AnonClass
-// MD-MUSTACHE-ANON-CLASS: # class AnonClass
// MD-ANON-INDEX: # namespace @nonymous_namespace
-// MD-ANON-INDEX: Anonymous Namespace
+// MD-ANON-INDEX: Anonymous Namespace
// MD-ANON-INDEX: ## Records
// MD-ANON-INDEX: * [AnonClass](AnonClass.md)
// MD-ANON-INDEX: ## Functions
// MD-ANON-INDEX: ### anonFunction
// MD-ANON-INDEX: *void anonFunction()*
-// MD-MUSTACHE-ANON-INDEX: # namespace @nonymous_namespace
-// MD-MUSTACHE-ANON-INDEX: Anonymous Namespace
-// MD-MUSTACHE-ANON-INDEX: ## Records
-// MD-MUSTACHE-ANON-INDEX: * [AnonClass](AnonClass.md)
-// MD-MUSTACHE-ANON-INDEX: ## Functions
-// MD-MUSTACHE-ANON-INDEX: ### anonFunction
-// MD-MUSTACHE-ANON-INDEX: *void anonFunction()*
-
// MD-PRIMARY-INDEX-LINE: *Defined at {{.*}}namespace-html-md.cpp#10*
-// MD-MUSTACHE-PRIMARY-INDEX-LINE: *Defined at {{.*}}namespace-html-md.cpp#10*
// MD-PRIMARY-CLASS-LINE: *Defined at {{.*}}namespace-html-md.cpp#12*
-// MD-MUSTACHE-PRIMARY-CLASS-LINE: *Defined at {{.*}}namespace-html-md.cpp#12*
// MD-PRIMARY-CLASS: # class ClassInPrimaryNamespace
// MD-PRIMARY-CLASS: Class in PrimaryNamespace
-// MD-MUSTACHE-PRIMARY-CLASS: # class ClassInPrimaryNamespace
-// MD-MUSTACHE-PRIMARY-CLASS: Class in PrimaryNamespace
-
// MD-NESTED-INDEX-LINE: *Defined at {{.*}}namespace-html-md.cpp#17*
-// MD-MUSTACHE-NESTED-INDEX-LINE: *Defined at {{.*}}namespace-html-md.cpp#17*
// MD-NESTED-CLASS-LINE: *Defined at {{.*}}namespace-html-md.cpp#19*
-// MD-MUSTACHE-NESTED-CLASS-LINE: *Defined at {{.*}}namespace-html-md.cpp#19*
// MD-NESTED-CLASS: # class ClassInNestedNamespace
// MD-NESTED-CLASS: Class in NestedNamespace
-// MD-MUSTACHE-NESTED-CLASS: # class ClassInNestedNamespace
-// MD-MUSTACHE-NESTED-CLASS: Class in NestedNamespace
-
// MD-NESTED-INDEX: # namespace NestedNamespace
// MD-NESTED-INDEX: Nested namespace
// MD-NESTED-INDEX: ## Records
@@ -98,17 +57,8 @@
// MD-NESTED-INDEX: *void functionInNestedNamespace()*
// MD-NESTED-INDEX: Function in NestedNamespace
-// MD-MUSTACHE-NESTED-INDEX: # namespace NestedNamespace
-// MD-MUSTACHE-NESTED-INDEX: Nested namespace
-// MD-MUSTACHE-NESTED-INDEX: ## Records
-// MD-MUSTACHE-NESTED-INDEX: * [ClassInNestedNamespace](ClassInNestedNamespace.md)
-// MD-MUSTACHE-NESTED-INDEX: ## Functions
-// MD-MUSTACHE-NESTED-INDEX: ### functionInNestedNamespace
-// MD-MUSTACHE-NESTED-INDEX: *void functionInNestedNamespace()*
-// MD-MUSTACHE-NESTED-INDEX: Function in NestedNamespace
-
// MD-PRIMARY-INDEX: # namespace PrimaryNamespace
-// MD-PRIMARY-INDEX: Primary Namespace
+// MD-PRIMARY-INDEX: Primary Namespace
// MD-PRIMARY-INDEX: ## Namespaces
// MD-PRIMARY-INDEX: * [NestedNamespace](NestedNamespace{{[\/]}}index.md)
// MD-PRIMARY-INDEX: ## Records
@@ -116,30 +66,14 @@
// MD-PRIMARY-INDEX: ## Functions
// MD-PRIMARY-INDEX: ### functionInPrimaryNamespace
// MD-PRIMARY-INDEX: *void functionInPrimaryNamespace()*
-// MD-PRIMARY-INDEX: Function in PrimaryNamespace
-
-// MD-MUSTACHE-PRIMARY-INDEX: # namespace PrimaryNamespace
-// MD-MUSTACHE-PRIMARY-INDEX: Primary Namespace
-// MD-MUSTACHE-PRIMARY-INDEX: ## Namespaces
-// MD-MUSTACHE-PRIMARY-INDEX: * [NestedNamespace](NestedNamespace{{[\/]}}index.md)
-// MD-MUSTACHE-PRIMARY-INDEX: ## Records
-// MD-MUSTACHE-PRIMARY-INDEX: * [ClassInPrimaryNamespace](ClassInPrimaryNamespace.md)
-// MD-MUSTACHE-PRIMARY-INDEX: ## Functions
-// MD-MUSTACHE-PRIMARY-INDEX: ### functionInPrimaryNamespace
-// MD-MUSTACHE-PRIMARY-INDEX: *void functionInPrimaryNamespace()*
-// MD-MUSTACHE-PRIMARY-INDEX: Function in PrimaryNamespace
+// MD-PRIMARY-INDEX: Function in PrimaryNamespace
// MD-ANOTHER-INDEX-LINE: *Defined at {{.*}}namespace-html-md.cpp#26*
-// MD-MUSTACHE-ANOTHER-INDEX-LINE: *Defined at {{.*}}namespace-html-md.cpp#26*
// MD-ANOTHER-CLASS-LINE: *Defined at {{.*}}namespace-html-md.cpp#28*
-// MD-MUSTACHE-ANOTHER-CLASS-LINE: *Defined at {{.*}}namespace-html-md.cpp#28*
// MD-ANOTHER-CLASS: # class ClassInAnotherNamespace
-// MD-ANOTHER-CLASS: Class in AnotherNamespace
-
-// MD-MUSTACHE-ANOTHER-CLASS: # class ClassInAnotherNamespace
-// MD-MUSTACHE-ANOTHER-CLASS: Class in AnotherNamespace
+// MD-ANOTHER-CLASS: Class in AnotherNamespace
// MD-ANOTHER-INDEX: # namespace AnotherNamespace
// MD-ANOTHER-INDEX: AnotherNamespace
@@ -150,26 +84,11 @@
// MD-ANOTHER-INDEX: *void functionInAnotherNamespace()*
// MD-ANOTHER-INDEX: Function in AnotherNamespace
-// MD-MUSTACHE-ANOTHER-INDEX: # namespace AnotherNamespace
-// MD-MUSTACHE-ANOTHER-INDEX: AnotherNamespace
-// MD-MUSTACHE-ANOTHER-INDEX: ## Records
-// MD-MUSTACHE-ANOTHER-INDEX: * [ClassInAnotherNamespace](ClassInAnotherNamespace.md)
-// MD-MUSTACHE-ANOTHER-INDEX: ## Functions
-// MD-MUSTACHE-ANOTHER-INDEX: ### functionInAnotherNamespace
-// MD-MUSTACHE-ANOTHER-INDEX: *void functionInAnotherNamespace()*
-// MD-MUSTACHE-ANOTHER-INDEX: Function in AnotherNamespace
-
// MD-GLOBAL-INDEX: # Global Namespace
// MD-GLOBAL-INDEX: ## Namespaces
-// MD-GLOBAL-INDEX: * [@nonymous_namespace](..{{[\/]}}@nonymous_namespace{{[\/]}}index.md)
-// MD-GLOBAL-INDEX: * [AnotherNamespace](..{{[\/]}}AnotherNamespace{{[\/]}}index.md)
-// MD-GLOBAL-INDEX: * [PrimaryNamespace](..{{[\/]}}PrimaryNamespace{{[\/]}}index.md)
-
-// MD-MUSTACHE-GLOBAL-INDEX: # Global Namespace
-// MD-MUSTACHE-GLOBAL-INDEX: ## Namespaces
-// MD-MUSTACHE-GLOBAL-INDEX: * [@nonymous_namespace]({{.*}}{{[\/]}}@nonymous_namespace{{[\/]}}index.md)
-// MD-MUSTACHE-GLOBAL-INDEX: * [AnotherNamespace]({{.*}}{{[\/]}}AnotherNamespace{{[\/]}}index.md)
-// MD-MUSTACHE-GLOBAL-INDEX: * [PrimaryNamespace]({{.*}}{{[\/]}}PrimaryNamespace{{[\/]}}index.md)
+// MD-GLOBAL-INDEX: * [@nonymous_namespace]({{.*}}{{[\/]}}@nonymous_namespace{{[\/]}}index.md)
+// MD-GLOBAL-INDEX: * [AnotherNamespace]({{.*}}{{[\/]}}AnotherNamespace{{[\/]}}index.md)
+// MD-GLOBAL-INDEX: * [PrimaryNamespace]({{.*}}{{[\/]}}PrimaryNamespace{{[\/]}}index.md)
// MD-ALL-FILES: # All Files
// MD-ALL-FILES: ## [@nonymous_namespace](@nonymous_namespace{{[\/]}}index.md)
@@ -177,18 +96,7 @@
// MD-ALL-FILES: ## [GlobalNamespace](GlobalNamespace{{[\/]}}index.md)
// MD-ALL-FILES: ## [PrimaryNamespace](PrimaryNamespace{{[\/]}}index.md)
-// MD-MUSTACHE-ALL-FILES: # All Files
-// MD-MUSTACHE-ALL-FILES: ## [@nonymous_namespace](@nonymous_namespace{{[\/]}}index.md)
-// MD-MUSTACHE-ALL-FILES: ## [AnotherNamespace](AnotherNamespace{{[\/]}}index.md)
-// MD-MUSTACHE-ALL-FILES: ## [GlobalNamespace](GlobalNamespace{{[\/]}}index.md)
-// MD-MUSTACHE-ALL-FILES: ## [PrimaryNamespace](PrimaryNamespace{{[\/]}}index.md)
-
// MD-INDEX: # C/C++ Reference
// MD-INDEX: * Namespace: [@nonymous_namespace](@nonymous_namespace)
// MD-INDEX: * Namespace: [AnotherNamespace](AnotherNamespace)
// MD-INDEX: * Namespace: [PrimaryNamespace](PrimaryNamespace)
-
-// MD-MUSTACHE-INDEX: # C/C++ Reference
-// MD-MUSTACHE-INDEX: * Namespace: [@nonymous_namespace](@nonymous_namespace)
-// MD-MUSTACHE-INDEX: * Namespace: [AnotherNamespace](AnotherNamespace)
-// MD-MUSTACHE-INDEX: * Namespace: [PrimaryNamespace](PrimaryNamespace)
diff --git a/clang-tools-extra/test/clang-doc/md/nested-pointer-qualifiers.cpp b/clang-tools-extra/test/clang-doc/md/nested-pointer-qualifiers.cpp
index b2db895ba1e4f..2552177cefbc4 100644
--- a/clang-tools-extra/test/clang-doc/md/nested-pointer-qualifiers.cpp
+++ b/clang-tools-extra/test/clang-doc/md/nested-pointer-qualifiers.cpp
@@ -1,8 +1,5 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --output=%t --format=md --executor=standalone %S/../Inputs/nested-pointer-qualifiers.cpp
-// RUN: FileCheck %s --check-prefix=MD < %t/GlobalNamespace/index.md
-// RUN: clang-doc --output=%t --format=md_mustache --executor=standalone %S/../Inputs/nested-pointer-qualifiers.cpp
// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < %t/md/GlobalNamespace/index.md
-// MD: *void foo(const int *const * ptr)*
// MD-MUSTACHE: *void foo(const int *const * ptr)*
diff --git a/clang-tools-extra/test/clang-doc/md/templates.cpp b/clang-tools-extra/test/clang-doc/md/templates.cpp
index 7b6d3b613fc04..68884ba34338b 100644
--- a/clang-tools-extra/test/clang-doc/md/templates.cpp
+++ b/clang-tools-extra/test/clang-doc/md/templates.cpp
@@ -1,49 +1,23 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: clang-doc --doxygen --executor=standalone %S/../Inputs/templates.cpp -output=%t/docs --format=md
-// RUN: FileCheck %s --check-prefix=MD < %t/docs/GlobalNamespace/index.md
-// RUN: clang-doc --doxygen --executor=standalone %S/../Inputs/templates.cpp -output=%t/docs --format=md_mustache
-// RUN: FileCheck %s --check-prefix=MD-MUSTACHE < %t/docs/md/GlobalNamespace/index.md
+// RUN: FileCheck %s --check-prefix=MD < %t/docs/md/GlobalNamespace/index.md
// MD: # Global Namespace
// MD: ## Functions
-// MD-MUSTACHE: # Global Namespace
-// MD-MUSTACHE: ## Functions
-
// MD: ### ParamPackFunction
// MD: *void ParamPackFunction(T... args)*
-// MD-MUSTACHE: ### ParamPackFunction
-// MD-MUSTACHE: *void ParamPackFunction(T... args)*
-
// MD: ### function
// MD: *void function(T x)*
// MD: *Defined at {{.*}}templates.cpp#3*
-// MD-MUSTACHE: ### function
-// MD-MUSTACHE: *void function(T x)*
-// MD-MUSTACHE: *Defined at {{.*}}templates.cpp#3*
-
-// MD: ### longFunction
-// MD: *void longFunction(A a, B b, C c, D d, E e)*
-// MD: *Defined at {{.*}}templates.cpp#6*
-
// MD: ### function
// MD: *void function(bool x)*
// MD: *Defined at {{.*}}templates.cpp#8*
-// MD-MUSTACHE: ### function
-// MD-MUSTACHE: *void function(bool x)*
-// MD-MUSTACHE: *Defined at {{.*}}templates.cpp#8*
-
// MD: ### func_with_tuple_param
// MD: *tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> t)*
// MD: *Defined at {{.*}}templates.cpp#18*
// MD: A function with a tuple parameter
// MD: **t** The input to func_with_tuple_param
-
-// MD-MUSTACHE: ### func_with_tuple_param
-// MD-MUSTACHE: *tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> t)*
-// MD-MUSTACHE: *Defined at {{.*}}templates.cpp#18*
-// MD-MUSTACHE: A function with a tuple parameter
-// MD-MUSTACHE: **t** The input to func_with_tuple_param
diff --git a/clang-tools-extra/unittests/clang-doc/CMakeLists.txt b/clang-tools-extra/unittests/clang-doc/CMakeLists.txt
index 97a26f0e24d09..d1fe314b59190 100644
--- a/clang-tools-extra/unittests/clang-doc/CMakeLists.txt
+++ b/clang-tools-extra/unittests/clang-doc/CMakeLists.txt
@@ -26,7 +26,6 @@ add_extra_unittest(ClangDocTests
ClangDocTest.cpp
GeneratorTest.cpp
HTMLGeneratorTest.cpp
- MDGeneratorTest.cpp
MergeTest.cpp
SerializeTest.cpp
YAMLGeneratorTest.cpp
diff --git a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
deleted file mode 100644
index b4257cf65475d..0000000000000
--- a/clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-//===-- clang-doc/MDGeneratorTest.cpp -------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "ClangDocTest.h"
-#include "Generators.h"
-#include "Representation.h"
-#include "gtest/gtest.h"
-
-namespace clang {
-namespace doc {
-
-static std::unique_ptr<Generator> getMDGenerator() {
- auto G = doc::findGeneratorByName("md");
- if (!G)
- return nullptr;
- return std::move(G.get());
-}
-
-class MDGeneratorTest : public ClangDocContextTest {};
-
-TEST_F(MDGeneratorTest, emitNamespaceMD) {
- NamespaceInfo I;
- I.Name = "Namespace";
- Reference Ns[] = {Reference(EmptySID, "A", InfoType::IT_namespace)};
- I.Namespace = llvm::ArrayRef(Ns);
-
- Reference NewNamespace(EmptySID, "ChildNamespace", InfoType::IT_namespace);
- InfoNode<Reference> NewNamespaceNode(&NewNamespace);
- I.Children.Namespaces.push_back(NewNamespaceNode);
-
- Reference ChildStruct(EmptySID, "ChildStruct", InfoType::IT_record);
- InfoNode<Reference> ChildStructNode(&ChildStruct);
- I.Children.Records.push_back(ChildStructNode);
-
- FunctionInfo F;
- F.Name = "OneFunction";
- F.Access = AccessSpecifier::AS_none;
- InfoNode<FunctionInfo> FNode(&F);
- I.Children.Functions.push_back(FNode);
-
- EnumInfo E;
- E.Name = "OneEnum";
- InfoNode<EnumInfo> ENode(&E);
- I.Children.Enums.push_back(ENode);
-
- auto G = getMDGenerator();
- assert(G);
- std::string Buffer;
- llvm::raw_string_ostream Actual(Buffer);
- auto Err = G->generateDocForInfo(&I, Actual, getClangDocContext());
- assert(!Err);
- std::string Expected = R"raw(# namespace Namespace
-
-
-
-## Namespaces
-
-* [ChildNamespace](../ChildNamespace/index.md)
-
-
-## Records
-
-* [ChildStruct](../ChildStruct.md)
-
-
-## Functions
-
-### OneFunction
-
-* OneFunction()*
-
-
-
-## Enums
-
-| enum OneEnum |
-
-| Name | Value |
-
-
-)raw";
- EXPECT_EQ(Expected, Actual.str());
-}
-
-TEST_F(MDGeneratorTest, emitRecordMD) {
- RecordInfo I;
- I.Name = "r";
- Reference Ns[] = {Reference(EmptySID, "A", InfoType::IT_namespace)};
- I.Namespace = llvm::ArrayRef(Ns);
-
- I.DefLoc = Location(10, 10, "test.cpp");
- Location Loc1(12, 12, "test.cpp");
- InfoNode<Location> Loc1Node(&Loc1);
- I.Loc.push_back(Loc1Node);
-
- MemberTypeInfo M[] = {
- MemberTypeInfo(TypeInfo("int"), "X", AccessSpecifier::AS_private)};
- I.Members = llvm::ArrayRef(M);
- I.TagType = TagTypeKind::Class;
- Reference Parents[] = {Reference(EmptySID, "F", InfoType::IT_record)};
- I.Parents = llvm::ArrayRef(Parents);
- Reference VParents[] = {Reference(EmptySID, "G", InfoType::IT_record)};
- I.VirtualParents = llvm::ArrayRef(VParents);
-
- Reference ChildStruct(EmptySID, "ChildStruct", InfoType::IT_record);
- InfoNode<Reference> ChildStructNode(&ChildStruct);
- I.Children.Records.push_back(ChildStructNode);
- FunctionInfo F;
- F.Name = "OneFunction";
- InfoNode<FunctionInfo> FNode(&F);
- I.Children.Functions.push_back(FNode);
-
- EnumInfo E;
- E.Name = "OneEnum";
- InfoNode<EnumInfo> ENode(&E);
- I.Children.Enums.push_back(ENode);
-
- auto G = getMDGenerator();
- assert(G);
- std::string Buffer;
- llvm::raw_string_ostream Actual(Buffer);
- auto Err = G->generateDocForInfo(&I, Actual, getClangDocContext());
- assert(!Err);
- std::string Expected = R"raw(# class r
-
-*Defined at test.cpp#10*
-
-Inherits from F, G
-
-
-
-## Members
-
-private int X
-
-
-
-## Records
-
-ChildStruct
-
-
-
-## Functions
-
-### OneFunction
-
-*public OneFunction()*
-
-
-
-## Enums
-
-| enum OneEnum |
-
-| Name | Value |
-
-
-)raw";
- EXPECT_EQ(Expected, Actual.str());
-}
-
-TEST_F(MDGeneratorTest, emitFunctionMD) {
- FunctionInfo I;
- I.Name = "f";
- Reference Ns[] = {Reference(EmptySID, "A", InfoType::IT_namespace)};
- I.Namespace = llvm::ArrayRef(Ns);
-
- I.DefLoc = Location(10, 10, "test.cpp");
- Location Loc1(12, 12, "test.cpp");
- InfoNode<Location> Loc1Node(&Loc1);
- I.Loc.push_back(Loc1Node);
-
- I.Access = AccessSpecifier::AS_none;
-
- I.ReturnType = TypeInfo("void");
- FieldTypeInfo P[] = {FieldTypeInfo(TypeInfo("int"), "P")};
- I.Params = llvm::ArrayRef(P);
- I.IsMethod = true;
- I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
-
- auto G = getMDGenerator();
- assert(G);
- std::string Buffer;
- llvm::raw_string_ostream Actual(Buffer);
- auto Err = G->generateDocForInfo(&I, Actual, getClangDocContext());
- assert(!Err);
- std::string Expected = R"raw(### f
-
-*void f(int P)*
-
-*Defined at test.cpp#10*
-
-)raw";
-
- EXPECT_EQ(Expected, Actual.str());
-}
-
-TEST_F(MDGeneratorTest, emitEnumMD) {
- EnumInfo I;
- I.Name = "e";
- Reference Ns[] = {Reference(EmptySID, "A", InfoType::IT_namespace)};
- I.Namespace = llvm::ArrayRef(Ns);
-
- I.DefLoc = Location(10, 10, "test.cpp");
- Location Loc1(12, 12, "test.cpp");
- InfoNode<Location> Loc1Node(&Loc1);
- I.Loc.push_back(Loc1Node);
-
- EnumValueInfo EV[] = {EnumValueInfo("X")};
- I.Members = llvm::ArrayRef(EV);
- I.Scoped = true;
-
- auto G = getMDGenerator();
- assert(G);
- std::string Buffer;
- llvm::raw_string_ostream Actual(Buffer);
- auto Err = G->generateDocForInfo(&I, Actual, getClangDocContext());
- assert(!Err);
- std::string Expected = R"raw(| enum class e |
-
-| Name | Value |
-|---|---|
-| X | 0 |
-
-*Defined at test.cpp#10*
-
-)raw";
-
- EXPECT_EQ(Expected, Actual.str());
-}
-
-TEST_F(MDGeneratorTest, emitCommentMD) {
- FunctionInfo I;
- I.Name = "f";
-
- I.DefLoc = Location(10, 10, "test.cpp");
- I.ReturnType = TypeInfo("void");
- FieldTypeInfo PI[] = {FieldTypeInfo(TypeInfo("int"), "I"),
- FieldTypeInfo(TypeInfo("int"), "J")};
- I.Params = llvm::ArrayRef(PI);
- I.Access = AccessSpecifier::AS_none;
-
- CommentInfo Top;
- Top.Kind = CommentKind::CK_FullComment;
-
- llvm::SmallVector<CommentInfo, 8> TopChildren;
-
- // BlankLine
- CommentInfo BlankLine;
- BlankLine.Kind = CommentKind::CK_ParagraphComment;
- CommentInfo BlankText;
- BlankText.Kind = CommentKind::CK_TextComment;
- CommentInfo BlankChildren[] = {std::move(BlankText)};
- BlankLine.Children = BlankChildren;
- TopChildren.push_back(std::move(BlankLine));
-
- // Brief
- CommentInfo Brief;
- Brief.Kind = CommentKind::CK_ParagraphComment;
- CommentInfo BriefText;
- BriefText.Kind = CommentKind::CK_TextComment;
- BriefText.Name = "ParagraphComment";
- BriefText.Text = " Brief description.";
- CommentInfo BriefChildren[] = {std::move(BriefText)};
- Brief.Children = BriefChildren;
- TopChildren.push_back(std::move(Brief));
-
- // Extended
- CommentInfo Extended;
- Extended.Kind = CommentKind::CK_ParagraphComment;
- CommentInfo ExtText1;
- ExtText1.Kind = CommentKind::CK_TextComment;
- ExtText1.Text = " Extended description that";
- CommentInfo ExtText2;
- ExtText2.Kind = CommentKind::CK_TextComment;
- ExtText2.Text = " continues onto the next line.";
- CommentInfo ExtChildren[] = {std::move(ExtText1), std::move(ExtText2)};
- Extended.Children = ExtChildren;
- TopChildren.push_back(std::move(Extended));
-
- // HTML
- CommentInfo HTML;
- HTML.Kind = CommentKind::CK_ParagraphComment;
- CommentInfo HtmlText1;
- HtmlText1.Kind = CommentKind::CK_TextComment;
- CommentInfo HtmlStart;
- HtmlStart.Kind = CommentKind::CK_HTMLStartTagComment;
- HtmlStart.Name = "ul";
- StringRef Keys[] = {"class"};
- StringRef Values[] = {"test"};
- HtmlStart.AttrKeys = Keys;
- HtmlStart.AttrValues = Values;
- CommentInfo HtmlStartLi;
- HtmlStartLi.Kind = CommentKind::CK_HTMLStartTagComment;
- HtmlStartLi.Name = "li";
- CommentInfo HtmlText2;
- HtmlText2.Kind = CommentKind::CK_TextComment;
- HtmlText2.Text = " Testing.";
- CommentInfo HtmlEnd;
- HtmlEnd.Kind = CommentKind::CK_HTMLEndTagComment;
- HtmlEnd.Name = "ul";
- HtmlEnd.SelfClosing = true;
- CommentInfo HtmlChildren[] = {std::move(HtmlText1), std::move(HtmlStart),
- std::move(HtmlStartLi), std::move(HtmlText2),
- std::move(HtmlEnd)};
- HTML.Children = HtmlChildren;
- TopChildren.push_back(std::move(HTML));
-
- // Verbatim
- CommentInfo Verbatim;
- Verbatim.Kind = CommentKind::CK_VerbatimBlockComment;
- Verbatim.Name = "verbatim";
- Verbatim.CloseName = "endverbatim";
- CommentInfo VerbLine;
- VerbLine.Kind = CommentKind::CK_VerbatimBlockLineComment;
- VerbLine.Text = " The description continues.";
- CommentInfo VerbChildren[] = {std::move(VerbLine)};
- Verbatim.Children = VerbChildren;
- TopChildren.push_back(std::move(Verbatim));
-
- // ParamOut
- CommentInfo ParamOut;
- ParamOut.Kind = CommentKind::CK_ParamCommandComment;
- ParamOut.Direction = "[out]";
- ParamOut.ParamName = "I";
- ParamOut.Explicit = true;
- CommentInfo ParamOutPara;
- ParamOutPara.Kind = CommentKind::CK_ParagraphComment;
- CommentInfo ParamOutText1;
- ParamOutText1.Kind = CommentKind::CK_TextComment;
- CommentInfo ParamOutText2;
- ParamOutText2.Kind = CommentKind::CK_TextComment;
- ParamOutText2.Text = "is a parameter.";
- CommentInfo ParamOutParaChildren[] = {std::move(ParamOutText1),
- std::move(ParamOutText2)};
- ParamOutPara.Children = ParamOutParaChildren;
- CommentInfo ParamOutChildren[] = {std::move(ParamOutPara)};
- ParamOut.Children = ParamOutChildren;
- TopChildren.push_back(std::move(ParamOut));
-
- // ParamIn
- CommentInfo ParamIn;
- ParamIn.Kind = CommentKind::CK_ParamCommandComment;
- ParamIn.Direction = "[in]";
- ParamIn.ParamName = "J";
- CommentInfo ParamInPara;
- ParamInPara.Kind = CommentKind::CK_ParagraphComment;
- CommentInfo ParamInText1;
- ParamInText1.Kind = CommentKind::CK_TextComment;
- ParamInText1.Text = "is a parameter.";
- CommentInfo ParamInText2;
- ParamInText2.Kind = CommentKind::CK_TextComment;
- CommentInfo ParamInParaChildren[] = {std::move(ParamInText1),
- std::move(ParamInText2)};
- ParamInPara.Children = ParamInParaChildren;
- CommentInfo ParamInChildren[] = {std::move(ParamInPara)};
- ParamIn.Children = ParamInChildren;
- TopChildren.push_back(std::move(ParamIn));
-
- // Return
- CommentInfo Return;
- Return.Kind = CommentKind::CK_BlockCommandComment;
- Return.Name = "return";
- Return.Explicit = true;
- CommentInfo ReturnPara;
- ReturnPara.Kind = CommentKind::CK_ParagraphComment;
- CommentInfo ReturnText1;
- ReturnText1.Kind = CommentKind::CK_TextComment;
- ReturnText1.Text = "void";
- CommentInfo ReturnParaChildren[] = {std::move(ReturnText1)};
- ReturnPara.Children = ReturnParaChildren;
- CommentInfo ReturnChildren[] = {std::move(ReturnPara)};
- Return.Children = ReturnChildren;
- TopChildren.push_back(std::move(Return));
-
- Top.Children = TopChildren;
-
- InfoNode<CommentInfo> TopNode(&Top);
- I.Description.push_back(TopNode);
-
- auto G = getMDGenerator();
- assert(G);
- std::string Buffer;
- llvm::raw_string_ostream Actual(Buffer);
- auto Err = G->generateDocForInfo(&I, Actual, getClangDocContext());
- assert(!Err);
- std::string Expected =
- R"raw(### f
-
-*void f(int I, int J)*
-
-*Defined at test.cpp#10*
-
-
-
- Brief description.
-
- Extended description that continues onto the next line.
-
-<ul "class=test">
-
-<li>
-
- Testing.</ul>
-
-
-
- The description continues.
-
-**I** [out] is a parameter.
-
-**J** is a parameter.
-
-**return** void
-
-)raw";
-
- EXPECT_EQ(Expected, Actual.str());
-}
-
-} // namespace doc
-} // namespace clang
More information about the cfe-commits
mailing list