1e78f3018SJulie Hockett //===-- Generators.h - ClangDoc Generator ----------------------*- C++ -*-===// 2e78f3018SJulie Hockett // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e78f3018SJulie Hockett // 7e78f3018SJulie Hockett //===----------------------------------------------------------------------===// 8e78f3018SJulie Hockett // Generator classes for converting declaration information into documentation 9e78f3018SJulie Hockett // in a specified format. 10e78f3018SJulie Hockett //===----------------------------------------------------------------------===// 11e78f3018SJulie Hockett 12e78f3018SJulie Hockett #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H 13e78f3018SJulie Hockett #define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H 14e78f3018SJulie Hockett 15e78f3018SJulie Hockett #include "Representation.h" 16e78f3018SJulie Hockett #include "llvm/Support/Error.h" 17e78f3018SJulie Hockett #include "llvm/Support/Registry.h" 18e78f3018SJulie Hockett 19e78f3018SJulie Hockett namespace clang { 20e78f3018SJulie Hockett namespace doc { 21e78f3018SJulie Hockett 22e78f3018SJulie Hockett // Abstract base class for generators. 23e78f3018SJulie Hockett // This is expected to be implemented and exposed via the GeneratorRegistry. 24e78f3018SJulie Hockett class Generator { 25e78f3018SJulie Hockett public: 26e78f3018SJulie Hockett virtual ~Generator() = default; 27e78f3018SJulie Hockett 287b8c7e02SBrett Wilson // Write out the decl info for the objects in the given map in the specified 297b8c7e02SBrett Wilson // format. 307b8c7e02SBrett Wilson virtual llvm::Error 317b8c7e02SBrett Wilson generateDocs(StringRef RootDir, 327b8c7e02SBrett Wilson llvm::StringMap<std::unique_ptr<doc::Info>> Infos, 33acd35f6cSDiego Astiazaran const ClangDocContext &CDCtx) = 0; 347b8c7e02SBrett Wilson 357dfe0bc3SDiego Astiazaran // This function writes a file with the index previously constructed. 367dfe0bc3SDiego Astiazaran // It can be overwritten by any of the inherited generators. 377dfe0bc3SDiego Astiazaran // If the override method wants to run this it should call 387dfe0bc3SDiego Astiazaran // Generator::createResources(CDCtx); 3972e1f7f9SJulie Hockett virtual llvm::Error createResources(ClangDocContext &CDCtx); 407dfe0bc3SDiego Astiazaran 417b8c7e02SBrett Wilson // Write out one specific decl info to the destination stream. 427b8c7e02SBrett Wilson virtual llvm::Error generateDocForInfo(Info *I, llvm::raw_ostream &OS, 437b8c7e02SBrett Wilson const ClangDocContext &CDCtx) = 0; 447b8c7e02SBrett Wilson 457dfe0bc3SDiego Astiazaran static void addInfoToIndex(Index &Idx, const doc::Info *Info); 46e78f3018SJulie Hockett }; 47e78f3018SJulie Hockett 48e78f3018SJulie Hockett typedef llvm::Registry<Generator> GeneratorRegistry; 49e78f3018SJulie Hockett 50e78f3018SJulie Hockett llvm::Expected<std::unique_ptr<Generator>> 51e78f3018SJulie Hockett findGeneratorByName(llvm::StringRef Format); 52e78f3018SJulie Hockett 53671bac74SJulie Hockett std::string getTagType(TagTypeKind AS); 54671bac74SJulie Hockett 55e78f3018SJulie Hockett } // namespace doc 56e78f3018SJulie Hockett } // namespace clang 57e78f3018SJulie Hockett 58*b735c66dSThomas Fransham namespace llvm { 59*b735c66dSThomas Fransham extern template class Registry<clang::doc::Generator>; 60*b735c66dSThomas Fransham } // namespace llvm 61*b735c66dSThomas Fransham 62e78f3018SJulie Hockett #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H 63