clang-tools 20.0.0git
Generators.h
Go to the documentation of this file.
1//===-- Generators.h - ClangDoc Generator ----------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8// Generator classes for converting declaration information into documentation
9// in a specified format.
10//===----------------------------------------------------------------------===//
11
12#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
13#define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
14
15#include "Representation.h"
16#include "llvm/Support/Error.h"
17#include "llvm/Support/Registry.h"
18
19namespace clang {
20namespace doc {
21
22// Abstract base class for generators.
23// This is expected to be implemented and exposed via the GeneratorRegistry.
24class Generator {
25public:
26 virtual ~Generator() = default;
27
28 // Write out the decl info for the objects in the given map in the specified
29 // format.
30 virtual llvm::Error
31 generateDocs(StringRef RootDir,
32 llvm::StringMap<std::unique_ptr<doc::Info>> Infos,
33 const ClangDocContext &CDCtx) = 0;
34
35 // This function writes a file with the index previously constructed.
36 // It can be overwritten by any of the inherited generators.
37 // If the override method wants to run this it should call
38 // Generator::createResources(CDCtx);
39 virtual llvm::Error createResources(ClangDocContext &CDCtx);
40
41 // Write out one specific decl info to the destination stream.
42 virtual llvm::Error generateDocForInfo(Info *I, llvm::raw_ostream &OS,
43 const ClangDocContext &CDCtx) = 0;
44
45 static void addInfoToIndex(Index &Idx, const doc::Info *Info);
46};
47
48typedef llvm::Registry<Generator> GeneratorRegistry;
49
50llvm::Expected<std::unique_ptr<Generator>>
51findGeneratorByName(llvm::StringRef Format);
52
53std::string getTagType(TagTypeKind AS);
54
55} // namespace doc
56} // namespace clang
57
58#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
llvm::raw_string_ostream OS
Definition: TraceTests.cpp:160
virtual llvm::Error generateDocForInfo(Info *I, llvm::raw_ostream &OS, const ClangDocContext &CDCtx)=0
virtual llvm::Error generateDocs(StringRef RootDir, llvm::StringMap< std::unique_ptr< doc::Info > > Infos, const ClangDocContext &CDCtx)=0
static void addInfoToIndex(Index &Idx, const doc::Info *Info)
Definition: Generators.cpp:59
virtual ~Generator()=default
virtual llvm::Error createResources(ClangDocContext &CDCtx)
Definition: Generators.cpp:45
std::string getTagType(TagTypeKind AS)
Definition: Generators.cpp:29
llvm::Expected< std::unique_ptr< Generator > > findGeneratorByName(llvm::StringRef Format)
Definition: Generators.cpp:17
llvm::Registry< Generator > GeneratorRegistry
Definition: Generators.h:48
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
A base struct for Infos.