MCPcopy Create free account
hub / github.com/KDAB/codebrowser / generate

Method generate

generator/annotator.cpp:233–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233bool Annotator::generate(clang::Sema &Sema, bool WasInDatabase)
234{
235 std::ofstream fileIndex;
236 fileIndex.open(projectManager.outputPrefix + "/fileIndex", std::ios::app);
237 if (!fileIndex) {
238 create_directories(projectManager.outputPrefix);
239 fileIndex.open(projectManager.outputPrefix + "/fileIndex", std::ios::app);
240 if (!fileIndex) {
241 std::cerr << "Can't generate index for " << std::endl;
242 return false;
243 }
244 }
245
246 // make sure the main file is in the cache.
247 htmlNameForFile(getSourceMgr().getMainFileID());
248
249 std::set<std::string> done;
250 for(auto it : cache) {
251 if (!it.second.first)
252 continue;
253 const std::string &fn = it.second.second;
254 if (done.count(fn))
255 continue;
256 done.insert(fn);
257
258 auto project_it = std::find_if(projectManager.projects.cbegin(), projectManager.projects.cend(),
259 [&fn](const ProjectInfo &it)
260 { return llvm::StringRef(fn).startswith(it.name); } );
261 if (project_it == projectManager.projects.cend()) {
262 std::cerr << "GENERATION ERROR: " << fn << " not in a project" << std::endl;
263 continue;
264 }
265
266 clang::FileID FID = it.first;
267
268 Generator &g = generator(FID);
269
270 syntaxHighlight(g, FID, Sema);
271// clang::html::HighlightMacros(R, FID, PP);
272
273 std::string footer;
274 clang::FileID mainFID = getSourceMgr().getMainFileID();
275 if (FID != mainFID) {
276 footer = "Generated while processing <a href='" % pathTo(FID, mainFID) % "'>" % htmlNameForFile(mainFID) % "</a><br/>";
277 }
278
279 auto now = time(0);
280 auto tm = localtime(&now);
281 char buf[80];
282 strftime(buf, sizeof(buf), "%Y-%b-%d", tm);
283
284 const ProjectInfo &projectinfo = *project_it;
285 footer %= "Generated on <em>" % std::string(buf) % "</em>"
286 % " from project " % projectinfo.name;
287 if (!projectinfo.revision.empty())
288 footer %= " revision <em>" % projectinfo.revision % "</em>";
289
290 /* << " from file <a href='" << projectinfo.fileRepoUrl(filename) << "'>" << filename << "</a>"

Callers

nothing calls this directly

Calls 5

create_directoriesFunction · 0.85
TwineClass · 0.85
normalizeForfnIndexFunction · 0.85
openMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected