Skip to content

Commit 0037a03

Browse files
committed
tidy public apis
1 parent 6ddb9d1 commit 0037a03

File tree

4 files changed

+57
-37
lines changed

4 files changed

+57
-37
lines changed

source/lib/AsciidocGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ class AsciidocGenerator : public Generator
744744
llvm::Error
745745
generateDocs(
746746
StringRef RootDir,
747-
llvm::StringMap<std::unique_ptr<mrdox::Info>> Infos,
747+
InfoMap const& Infos,
748748
ClangDocContext const& CDCtx) override;
749749

750750
llvm::Error
@@ -765,7 +765,7 @@ llvm::Error
765765
AsciidocGenerator::
766766
generateDocs(
767767
StringRef RootDir,
768-
llvm::StringMap<std::unique_ptr<mrdox::Info>> Infos,
768+
InfoMap const& Infos,
769769
ClangDocContext const& CDCtx)
770770
{
771771
// Track which directories we already tried to create.

source/lib/Generators.h

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,50 @@ namespace mrdox {
2424

2525
struct ClangDocContext;
2626

27-
// Abstract base class for generators.
28-
// This is expected to be implemented and exposed via the GeneratorRegistry.
29-
class Generator {
27+
/** The representation of the source code under analysis.
28+
*/
29+
using InfoMap = llvm::StringMap<
30+
std::unique_ptr<mrdox::Info>>;
31+
32+
class Generator
33+
{
3034
public:
31-
virtual ~Generator() = default;
32-
33-
// Write out the decl info for the objects in the given map in the specified
34-
// format.
35-
virtual llvm::Error
36-
generateDocs(StringRef RootDir,
37-
llvm::StringMap<std::unique_ptr<mrdox::Info>> Infos,
38-
const ClangDocContext &CDCtx) = 0;
39-
40-
// This function writes a file with the index previously constructed.
41-
// It can be overwritten by any of the inherited generators.
42-
// If the override method wants to run this it should call
43-
// Generator::createResources(CDCtx);
44-
virtual llvm::Error createResources(ClangDocContext &CDCtx);
45-
46-
// Write out one specific decl info to the destination stream.
47-
virtual llvm::Error generateDocForInfo(Info *I, llvm::raw_ostream &OS,
48-
const ClangDocContext &CDCtx) = 0;
49-
50-
static void addInfoToIndex(Index &Idx, const mrdox::Info *Info);
35+
virtual ~Generator() = default;
36+
37+
// Write out the decl info for the objects in
38+
// the given map in the specified format.
39+
virtual
40+
llvm::Error
41+
generateDocs(
42+
StringRef RootDir,
43+
InfoMap const& Infos,
44+
ClangDocContext const& CDCtx) = 0;
45+
46+
// This function writes a file with the index previously constructed.
47+
// It can be overwritten by any of the inherited generators.
48+
// If the override method wants to run this it should call
49+
// Generator::createResources(CDCtx);
50+
virtual
51+
llvm::Error
52+
createResources(
53+
ClangDocContext& CDCtx);
54+
55+
// Write out one specific decl info to the destination stream.
56+
virtual
57+
llvm::Error
58+
generateDocForInfo(
59+
Info* I, // VFALCO Why not const?
60+
llvm::raw_ostream& OS,
61+
ClangDocContext const& CDCtx) = 0;
62+
63+
static
64+
void
65+
addInfoToIndex(
66+
Index& Idx,
67+
mrdox::Info const* Info);
5168
};
5269

70+
// VFALCO a global?
5371
typedef llvm::Registry<Generator> GeneratorRegistry;
5472

5573
llvm::Expected<std::unique_ptr<Generator>>
@@ -60,4 +78,4 @@ std::string getTagType(TagTypeKind AS);
6078
} // namespace mrdox
6179
} // namespace clang
6280

63-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_GENERATOR_H
81+
#endif

source/lib/XMLGenerator.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,12 @@ class XMLGenerator
113113
{
114114

115115
public:
116-
using InfoMap = llvm::StringMap<
117-
std::unique_ptr<mrdox::Info>>;
118-
119116
static char const* Format;
120117

121118
llvm::Error
122119
generateDocs(
123120
llvm::StringRef RootDir,
124-
InfoMap Infos,
121+
InfoMap const& Infos,
125122
ClangDocContext const& CDCtx) override;
126123

127124
llvm::Error
@@ -177,7 +174,7 @@ llvm::Error
177174
XMLGenerator::
178175
generateDocs(
179176
llvm::StringRef RootDir,
180-
InfoMap Infos,
177+
InfoMap const& Infos,
181178
ClangDocContext const& CDCtx)
182179
{
183180
llvm::SmallString<256> filename(CDCtx.OutDirectory);

source/mrdox/Main.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,23 @@ main(int argc, const char** argv)
9797
//--------------------------------------------
9898

9999
// Ensure the root output directory exists.
100-
if (std::error_code Err = llvm::sys::fs::create_directories(CDCtx.OutDirectory);
101-
Err != std::error_code()) {
100+
if (std::error_code Err =
101+
llvm::sys::fs::create_directories(CDCtx.OutDirectory);
102+
Err != std::error_code())
103+
{
102104
llvm::errs() << "Failed to create directory '" << CDCtx.OutDirectory << "'\n";
103-
return 1;
105+
return EXIT_FAILURE;
104106
}
105107

106108
// Run the generator.
107109
llvm::outs() << "Generating docs...\n";
108-
if (auto Err =
109-
CDCtx.G->generateDocs(CDCtx.OutDirectory, std::move(CDCtx.USRToInfo), CDCtx)) {
110+
if(auto Err = CDCtx.G->generateDocs(
111+
CDCtx.OutDirectory,
112+
std::move(CDCtx.USRToInfo),
113+
CDCtx))
114+
{
110115
llvm::errs() << toString(std::move(Err)) << "\n";
111-
return 1;
116+
return EXIT_FAILURE;
112117
}
113118

114119
//

0 commit comments

Comments
 (0)