1 //===-- Generators.h - ClangDoc Generator ----------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 // Generator classes for converting declaration information into documentation
10 // in a specified format.
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
14 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
15 
16 #include "Representation.h"
17 #include "llvm/Support/Error.h"
18 #include "llvm/Support/Registry.h"
19 
20 namespace clang {
21 namespace doc {
22 
23 // Abstract base class for generators.
24 // This is expected to be implemented and exposed via the GeneratorRegistry.
25 class Generator {
26 public:
27   virtual ~Generator() = default;
28 
29   // Write out the decl info in the specified format.
30   virtual bool generateDocForInfo(Info *I, llvm::raw_ostream &OS) = 0;
31 };
32 
33 typedef llvm::Registry<Generator> GeneratorRegistry;
34 
35 llvm::Expected<std::unique_ptr<Generator>>
36 findGeneratorByName(llvm::StringRef Format);
37 
38 } // namespace doc
39 } // namespace clang
40 
41 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
42