@@ -144,17 +144,22 @@ Error MustacheHTMLGenerator::generateDocs(
144
144
} else
145
145
return JSONGenerator.takeError ();
146
146
}
147
+ SmallString<128 > JSONPath;
148
+ sys::path::native (RootDir.str () + " /json" , JSONPath);
147
149
148
150
StringMap<json::Value> JSONFileMap;
149
151
{
150
152
llvm::TimeTraceScope TS (" Iterate JSON files" );
151
153
std::error_code EC;
152
- sys::fs::directory_iterator JSONIter (RootDir , EC);
154
+ sys::fs::directory_iterator JSONIter (JSONPath , EC);
153
155
std::vector<json::Value> JSONFiles;
154
156
JSONFiles.reserve (Infos.size ());
155
157
if (EC)
156
158
return createStringError (" Failed to create directory iterator." );
157
159
160
+ SmallString<128 > HTMLDirPath (RootDir.str () + " /html/" );
161
+ if (auto EC = sys::fs::create_directories (HTMLDirPath))
162
+ return createFileError (HTMLDirPath, EC);
158
163
while (JSONIter != sys::fs::directory_iterator ()) {
159
164
if (EC)
160
165
return createFileError (" Failed to iterate: " + JSONIter->path (), EC);
@@ -177,14 +182,15 @@ Error MustacheHTMLGenerator::generateDocs(
177
182
return Parsed.takeError ();
178
183
179
184
std::error_code FileErr;
180
- SmallString<16 > HTMLPath (Path.begin (), Path.end ());
181
- sys::path::replace_extension (HTMLPath, " html" );
182
- raw_fd_ostream InfoOS (HTMLPath, FileErr, sys::fs::OF_None);
185
+ SmallString<128 > HTMLFilePath (HTMLDirPath);
186
+ sys::path::append (HTMLFilePath, sys::path::filename (Path));
187
+ sys::path::replace_extension (HTMLFilePath, " html" );
188
+ raw_fd_ostream InfoOS (HTMLFilePath, FileErr, sys::fs::OF_None);
183
189
if (FileErr)
184
190
return createFileOpenError (Path, FileErr);
185
191
186
- if (Error Err = generateDocForJSON (*Parsed, sys::path::stem (HTMLPath ),
187
- HTMLPath , InfoOS, CDCtx))
192
+ if (Error Err = generateDocForJSON (*Parsed, sys::path::stem (HTMLFilePath ),
193
+ HTMLFilePath , InfoOS, CDCtx))
188
194
return Err;
189
195
JSONIter.increment (EC);
190
196
}
0 commit comments