@@ -133,19 +133,17 @@ std::string getFormatString() {
133
133
// GetMainExecutable (since some platforms don't support taking the
134
134
// address of main, and some platforms can't implement GetMainExecutable
135
135
// without being given the address of a function in the main executable).
136
- std::string GetExecutablePath (const char *Argv0, void *MainAddr) {
136
+ std::string getExecutablePath (const char *Argv0, void *MainAddr) {
137
137
return llvm::sys::fs::getMainExecutable (Argv0, MainAddr);
138
138
}
139
139
140
- llvm::Error GetAssetFiles (clang::doc::ClangDocContext &CDCtx) {
140
+ llvm::Error getAssetFiles (clang::doc::ClangDocContext &CDCtx) {
141
141
std::error_code Code;
142
+ llvm::SmallString<128 > FilePath = llvm::SmallString<128 >(UserAssetPath);
142
143
for (auto DirIt = llvm::sys::fs::directory_iterator (UserAssetPath, Code),
143
144
DirEnd = llvm::sys::fs::directory_iterator ();
144
145
!Code && DirIt != DirEnd; DirIt.increment (Code)) {
145
- llvm::SmallString<128 > FilePath = llvm::SmallString<128 >(DirIt->path ());
146
- if (!Code) {
147
- return llvm::createFileError (FilePath, Code);
148
- }
146
+ FilePath = llvm::SmallString<128 >(DirIt->path ());
149
147
if (llvm::sys::fs::is_regular_file (FilePath)) {
150
148
if (llvm::sys::path::extension (FilePath) == " .css" ) {
151
149
CDCtx.UserStylesheets .insert (CDCtx.UserStylesheets .begin (),
@@ -155,13 +153,16 @@ llvm::Error GetAssetFiles(clang::doc::ClangDocContext &CDCtx) {
155
153
}
156
154
}
157
155
}
156
+ if (Code) {
157
+ return llvm::createFileError (FilePath, Code);
158
+ }
158
159
return llvm::Error::success ();
159
160
}
160
161
161
- llvm::Error GetDefaultAssetFiles (const char *Argv0,
162
+ llvm::Error getDefaultAssetFiles (const char *Argv0,
162
163
clang::doc::ClangDocContext &CDCtx) {
163
- void *MainAddr = (void *)(intptr_t )GetExecutablePath ;
164
- std::string ClangDocPath = GetExecutablePath (Argv0, MainAddr);
164
+ void *MainAddr = (void *)(intptr_t )getExecutablePath ;
165
+ std::string ClangDocPath = getExecutablePath (Argv0, MainAddr);
165
166
llvm::SmallString<128 > NativeClangDocPath;
166
167
llvm::sys::path::native (ClangDocPath, NativeClangDocPath);
167
168
@@ -178,14 +179,14 @@ llvm::Error GetDefaultAssetFiles(const char *Argv0,
178
179
179
180
if (!llvm::sys::fs::is_regular_file (IndexJS)) {
180
181
return llvm::createStringError (llvm::inconvertibleErrorCode (),
181
- " error default index.js file at " + IndexJS +
182
- " \n " );
182
+ " error default index.js file missing at " +
183
+ IndexJS + " \n " );
183
184
}
184
185
185
186
if (!llvm::sys::fs::is_regular_file (DefaultStylesheet)) {
186
187
return llvm::createStringError (
187
188
llvm::inconvertibleErrorCode (),
188
- " error default clang-doc-default-stylesheet.css file at " +
189
+ " error default clang-doc-default-stylesheet.css file missing at " +
189
190
DefaultStylesheet + " \n " );
190
191
}
191
192
@@ -198,17 +199,17 @@ llvm::Error GetDefaultAssetFiles(const char *Argv0,
198
199
return llvm::Error::success ();
199
200
}
200
201
201
- llvm::Error GetHTMLAssetFiles (const char *Argv0,
202
+ llvm::Error getHtmlAssetFiles (const char *Argv0,
202
203
clang::doc::ClangDocContext &CDCtx) {
203
204
if (!UserAssetPath.empty () &&
204
205
!llvm::sys::fs::is_directory (std::string (UserAssetPath))) {
205
206
llvm::outs () << " Asset path supply is not a directory: " << UserAssetPath
206
207
<< " falling back to default\n " ;
207
208
}
208
209
if (llvm::sys::fs::is_directory (std::string (UserAssetPath))) {
209
- return GetAssetFiles (CDCtx);
210
+ return getAssetFiles (CDCtx);
210
211
}
211
- return GetDefaultAssetFiles (Argv0, CDCtx);
212
+ return getDefaultAssetFiles (Argv0, CDCtx);
212
213
}
213
214
214
215
int main (int argc, const char **argv) {
@@ -262,7 +263,7 @@ Example usage for a project using a compile commands database:
262
263
{" index.js" , " index_json.js" }};
263
264
264
265
if (Format == " html" ) {
265
- auto Err = GetHTMLAssetFiles (argv[0 ], CDCtx);
266
+ auto Err = getHtmlAssetFiles (argv[0 ], CDCtx);
266
267
if (Err) {
267
268
llvm::errs () << toString (std::move (Err)) << " \n " ;
268
269
return 1 ;
0 commit comments