@@ -42,6 +42,47 @@ getClangDocContext(std::vector<std::string> UserStylesheets = {},
42
42
return CDCtx;
43
43
}
44
44
45
+ static llvm::SmallString<128 > appendPathNative (StringRef Path,
46
+ StringRef Asset) {
47
+ llvm::SmallString<128 > Default;
48
+ llvm::sys::path::native (Path, Default);
49
+ llvm::sys::path::append (Default, Asset);
50
+ return Default;
51
+ }
52
+
53
+ static void getMustacheHtmlFiles (StringRef AssetsPath,
54
+ clang::doc::ClangDocContext &CDCtx) {
55
+ ASSERT_FALSE (AssetsPath.empty ());
56
+ ASSERT_TRUE (llvm::sys::fs::is_directory (AssetsPath));
57
+
58
+ llvm::SmallString<128 > DefaultStylesheet =
59
+ appendPathNative (AssetsPath, " clang-doc-mustache.css" );
60
+ llvm::SmallString<128 > NamespaceTemplate =
61
+ appendPathNative (AssetsPath, " namespace-template.mustache" );
62
+ llvm::SmallString<128 > ClassTemplate =
63
+ appendPathNative (AssetsPath, " class-template.mustache" );
64
+ llvm::SmallString<128 > EnumTemplate =
65
+ appendPathNative (AssetsPath, " enum-template.mustache" );
66
+ llvm::SmallString<128 > FunctionTemplate =
67
+ appendPathNative (AssetsPath, " function-template.mustache" );
68
+ llvm::SmallString<128 > CommentTemplate =
69
+ appendPathNative (AssetsPath, " comments-template.mustache" );
70
+ llvm::SmallString<128 > IndexJS =
71
+ appendPathNative (AssetsPath, " mustache-index.js" );
72
+
73
+ CDCtx.JsScripts .insert (CDCtx.JsScripts .begin (), IndexJS.c_str ());
74
+ CDCtx.UserStylesheets .insert (CDCtx.UserStylesheets .begin (),
75
+ DefaultStylesheet.str ().str ());
76
+ CDCtx.MustacheTemplates .insert (
77
+ {" namespace-template" , NamespaceTemplate.c_str ()});
78
+ CDCtx.MustacheTemplates .insert ({" class-template" , ClassTemplate.c_str ()});
79
+ CDCtx.MustacheTemplates .insert ({" enum-template" , EnumTemplate.c_str ()});
80
+ CDCtx.MustacheTemplates .insert (
81
+ {" function-template" , FunctionTemplate.c_str ()});
82
+ CDCtx.MustacheTemplates .insert (
83
+ {" comments-template" , CommentTemplate.c_str ()});
84
+ }
85
+
45
86
static void verifyFileContents (const Twine &Path, StringRef Contents) {
46
87
auto Buffer = MemoryBuffer::getFile (Path);
47
88
ASSERT_TRUE ((bool )Buffer);
@@ -87,8 +128,14 @@ TEST(HTMLMustacheGeneratorTest, generateDocs) {
87
128
assert (G && " Could not find HTMLMustacheGenerator" );
88
129
ClangDocContext CDCtx = getClangDocContext ();
89
130
90
- StringRef RootDir = " " ;
91
- EXPECT_THAT_ERROR (G->generateDocs (RootDir, {}, CDCtx), Succeeded ())
131
+ unittest::TempDir RootTestDirectory (" generateDocsTest" , /* Unique=*/ true );
132
+ CDCtx.OutDirectory = RootTestDirectory.path ();
133
+
134
+ // This seems wrong, but its unclear how else we would test this...
135
+ getMustacheHtmlFiles (" ../../../../../share/clang-doc" , CDCtx);
136
+
137
+ EXPECT_THAT_ERROR (G->generateDocs (RootTestDirectory.path (), {}, CDCtx),
138
+ Succeeded ())
92
139
<< " Failed to generate docs." ;
93
140
}
94
141
0 commit comments