[clang-tools-extra] [clang-doc] Add Markdown AST node type definitions (PR #205609)
Neil Nair via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 1 23:52:36 PDT 2026
================
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 "Markdown.h"
+
+namespace clang::doc::markdown {
+
+// TODO: print() currently outputs nodes flat with no indentation. Add
+// S-expression style formatting (as used by the Swift AST printer) to make
+// dumped trees easier to read.
+
+LLVM_DUMP_METHOD void InlineNode::dump() const { print(llvm::errs()); }
+
+void TextNode::print(llvm::raw_ostream &OS) const {
+ OS << "TextNode: " << getText() << "\n";
+}
+
+void InlineCodeNode::print(llvm::raw_ostream &OS) const {
+ OS << "InlineCodeNode: " << getCode() << "\n";
+}
+
+void EmphasisNode::print(llvm::raw_ostream &OS) const {
+ OS << "EmphasisNode\n";
+ for (const auto &Child : children())
+ Child.print(OS);
+}
+
+void StrongNode::print(llvm::raw_ostream &OS) const {
+ OS << "StrongNode\n";
+ for (const auto &Child : children())
+ Child.print(OS);
+}
+
+LLVM_DUMP_METHOD void BlockNode::dump() const { print(llvm::errs()); }
----------------
Neil-N4 wrote:
Good point, only the base classes and ListItemNode define dump() now
https://github.com/llvm/llvm-project/pull/205609
More information about the cfe-commits
mailing list