================ @@ -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); +} ---------------- ilovepi wrote:
Can we make the use of `:` consistent? Also... this is mostly the same code w/o any differences. This seems like something we can solve, either with a smarter class hierarchy or some `if constexpr` magic. For instance, the name is deterministic based on the kind, that could be a constexpr lookup in an array (yay enums), or could rely on some mild template programming. There's a few places in clang-doc where we were pretty clever and got much simpler code this way. This can be handled in a follow up if you prefer. https://github.com/llvm/llvm-project/pull/205609 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
