@@ -81,12 +81,6 @@ static llvm::cl::list<std::string> UserStylesheets(
81
81
llvm::cl::desc (" CSS stylesheets to extend the default styles." ),
82
82
llvm::cl::cat(ClangDocCategory));
83
83
84
- static llvm::cl::opt<std::string> UserAssetPath (
85
- " asset" ,
86
- llvm::cl::desc (" User supplied asset path to "
87
- " override the default css and js files for html output" ),
88
- llvm::cl::cat(ClangDocCategory));
89
-
90
84
static llvm::cl::opt<std::string> SourceRoot (" source-root" , llvm::cl::desc(R"(
91
85
Directory where processed files are stored.
92
86
Links to definition locations will only be
@@ -133,86 +127,16 @@ std::string getFormatString() {
133
127
// GetMainExecutable (since some platforms don't support taking the
134
128
// address of main, and some platforms can't implement GetMainExecutable
135
129
// without being given the address of a function in the main executable).
136
- std::string getExecutablePath (const char *Argv0, void *MainAddr) {
130
+ std::string GetExecutablePath (const char *Argv0, void *MainAddr) {
137
131
return llvm::sys::fs::getMainExecutable (Argv0, MainAddr);
138
132
}
139
133
140
- llvm::Error getAssetFiles (clang::doc::ClangDocContext &CDCtx) {
141
- using DirIt = llvm::sys::fs::directory_iterator;
142
- std::error_code FileErr;
143
- llvm::SmallString<128 > FilePath (UserAssetPath);
144
- for (DirIt DirStart = DirIt (UserAssetPath, FileErr),
145
- DirEnd;
146
- !FileErr && DirStart != DirEnd; DirStart.increment (FileErr)) {
147
- FilePath = DirStart->path ();
148
- if (llvm::sys::fs::is_regular_file (FilePath)) {
149
- if (llvm::sys::path::extension (FilePath) == " .css" )
150
- CDCtx.UserStylesheets .insert (CDCtx.UserStylesheets .begin (),
151
- std::string (FilePath));
152
- else if (llvm::sys::path::extension (FilePath) == " .js" )
153
- CDCtx.FilesToCopy .emplace_back (FilePath.str ());
154
- }
155
- }
156
- if (FileErr)
157
- return llvm::createFileError (FilePath, FileErr);
158
- return llvm::Error::success ();
159
- }
160
-
161
- llvm::Error getDefaultAssetFiles (const char *Argv0,
162
- clang::doc::ClangDocContext &CDCtx) {
163
- void *MainAddr = (void *)(intptr_t )getExecutablePath;
164
- std::string ClangDocPath = getExecutablePath (Argv0, MainAddr);
165
- llvm::SmallString<128 > NativeClangDocPath;
166
- llvm::sys::path::native (ClangDocPath, NativeClangDocPath);
167
-
168
- llvm::SmallString<128 > AssetsPath;
169
- AssetsPath = llvm::sys::path::parent_path (NativeClangDocPath);
170
- llvm::sys::path::append (AssetsPath, " .." , " share" , " clang" );
171
- llvm::SmallString<128 > DefaultStylesheet;
172
- llvm::sys::path::native (AssetsPath, DefaultStylesheet);
173
- llvm::sys::path::append (DefaultStylesheet,
174
- " clang-doc-default-stylesheet.css" );
175
- llvm::SmallString<128 > IndexJS;
176
- llvm::sys::path::native (AssetsPath, IndexJS);
177
- llvm::sys::path::append (IndexJS, " index.js" );
178
-
179
- llvm::outs () << " Using default asset: " << AssetsPath << " \n " ;
180
-
181
- if (!llvm::sys::fs::is_regular_file (IndexJS))
182
- return llvm::createStringError (llvm::inconvertibleErrorCode (),
183
- " default index.js file missing at " +
184
- IndexJS + " \n " );
185
-
186
- if (!llvm::sys::fs::is_regular_file (DefaultStylesheet))
187
- return llvm::createStringError (
188
- llvm::inconvertibleErrorCode (),
189
- " default clang-doc-default-stylesheet.css file missing at " +
190
- DefaultStylesheet + " \n " );
191
-
192
- CDCtx.UserStylesheets .insert (CDCtx.UserStylesheets .begin (),
193
- std::string (DefaultStylesheet));
194
- CDCtx.FilesToCopy .emplace_back (IndexJS.str ());
195
-
196
- return llvm::Error::success ();
197
- }
198
-
199
- llvm::Error getHtmlAssetFiles (const char *Argv0,
200
- clang::doc::ClangDocContext &CDCtx) {
201
- if (!UserAssetPath.empty () &&
202
- !llvm::sys::fs::is_directory (std::string (UserAssetPath)))
203
- llvm::outs () << " Asset path supply is not a directory: " << UserAssetPath
204
- << " falling back to default\n " ;
205
- if (llvm::sys::fs::is_directory (std::string (UserAssetPath)))
206
- return getAssetFiles (CDCtx);
207
- return getDefaultAssetFiles (Argv0, CDCtx);
208
- }
209
-
210
134
int main (int argc, const char **argv) {
211
135
llvm::sys::PrintStackTraceOnErrorSignal (argv[0 ]);
212
136
std::error_code OK;
213
137
214
138
const char *Overview =
215
- R"( Generates documentation from source code and comments.
139
+ R"( Generates documentation from source code and comments.
216
140
217
141
Example usage for files without flags (default):
218
142
@@ -258,9 +182,23 @@ Example usage for a project using a compile commands database:
258
182
{" index.js" , " index_json.js" }};
259
183
260
184
if (Format == " html" ) {
261
- if (auto Err = getHtmlAssetFiles (argv[0 ], CDCtx)) {
262
- llvm::outs () << " warning: " << toString (std::move (Err)) << " \n " ;
263
- }
185
+ void *MainAddr = (void *)(intptr_t )GetExecutablePath;
186
+ std::string ClangDocPath = GetExecutablePath (argv[0 ], MainAddr);
187
+ llvm::SmallString<128 > NativeClangDocPath;
188
+ llvm::sys::path::native (ClangDocPath, NativeClangDocPath);
189
+ llvm::SmallString<128 > AssetsPath;
190
+ AssetsPath = llvm::sys::path::parent_path (NativeClangDocPath);
191
+ llvm::sys::path::append (AssetsPath, " .." , " share" , " clang" );
192
+ llvm::SmallString<128 > DefaultStylesheet;
193
+ llvm::sys::path::native (AssetsPath, DefaultStylesheet);
194
+ llvm::sys::path::append (DefaultStylesheet,
195
+ " clang-doc-default-stylesheet.css" );
196
+ llvm::SmallString<128 > IndexJS;
197
+ llvm::sys::path::native (AssetsPath, IndexJS);
198
+ llvm::sys::path::append (IndexJS, " index.js" );
199
+ CDCtx.UserStylesheets .insert (CDCtx.UserStylesheets .begin (),
200
+ std::string (DefaultStylesheet));
201
+ CDCtx.FilesToCopy .emplace_back (IndexJS.str ());
264
202
}
265
203
266
204
// Mapping phase
0 commit comments