Doxygen
Loading...
Searching...
No Matches
plantuml.cpp File Reference
#include <mutex>
#include "plantuml.h"
#include "util.h"
#include "portable.h"
#include "config.h"
#include "doxygen.h"
#include "message.h"
#include "debug.h"
#include "fileinfo.h"
#include "dir.h"
#include "indexlist.h"
#include "stringutil.h"
Include dependency graph for plantuml.cpp:

Go to the source code of this file.

Functions

static void runPlantumlContent (const PlantumlManager::FilesMap &plantumlFiles, const PlantumlManager::ContentMap &plantumlContent, PlantumlManager::OutputFormat format)
static void print (const PlantumlManager::FilesMap &plantumlFiles)
static void print (const PlantumlManager::ContentMap &plantumlContent)
static void addPlantumlFiles (PlantumlManager::FilesMap &plantumlFiles, const std::string &key, const std::string &value)
static void addPlantumlContent (PlantumlManager::ContentMap &plantumlContent, const std::string &key, const QCString &outDir, const QCString &puContent, const QCString &srcFile, int srcLine)

Variables

static std::mutex g_PlantUmlMutex

Function Documentation

◆ addPlantumlContent()

void addPlantumlContent ( PlantumlManager::ContentMap & plantumlContent,
const std::string & key,
const QCString & outDir,
const QCString & puContent,
const QCString & srcFile,
int srcLine )
static

Definition at line 435 of file plantuml.cpp.

438{
439 auto kv = plantumlContent.find(key);
440 if (kv==plantumlContent.end())
441 {
442 kv = plantumlContent.emplace(key,PlantumlContent("",outDir,srcFile,srcLine)).first;
443 }
444 kv->second.content+=puContent;
445}

Referenced by PlantumlManager::insert().

◆ addPlantumlFiles()

void addPlantumlFiles ( PlantumlManager::FilesMap & plantumlFiles,
const std::string & key,
const std::string & value )
static

Definition at line 424 of file plantuml.cpp.

426{
427 auto kv = plantumlFiles.find(key);
428 if (kv==plantumlFiles.end())
429 {
430 kv = plantumlFiles.emplace(key,StringVector()).first;
431 }
432 kv->second.push_back(value);
433}
std::vector< std::string > StringVector
Definition containers.h:33

Referenced by PlantumlManager::insert().

◆ print() [1/2]

void print ( const PlantumlManager::ContentMap & plantumlContent)
static

Definition at line 412 of file plantuml.cpp.

413{
415 {
416 for (const auto &[key,content] : plantumlContent)
417 {
418 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Content PlantumlContent key: {}\n",key);
419 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Content:\n{}\n",content.content);
420 }
421 }
422}
@ Plantuml
Definition debug.h:39
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
static void print(DebugMask mask, int prio, fmt::format_string< Args... > fmt, Args &&... args)
Definition debug.h:76

References Debug::isFlagSet(), Debug::Plantuml, and Debug::print().

◆ print() [2/2]

void print ( const PlantumlManager::FilesMap & plantumlFiles)
static

Definition at line 397 of file plantuml.cpp.

398{
400 {
401 for (const auto &[key,list] : plantumlFiles)
402 {
403 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Files PlantumlFiles key:{} size:{}\n",key,list.size());
404 for (const auto &s : list)
405 {
406 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print list:{}\n",s);
407 }
408 }
409 }
410}

References Debug::isFlagSet(), Debug::Plantuml, and Debug::print().

Referenced by PlantumlManager::insert().

◆ runPlantumlContent()

void runPlantumlContent ( const PlantumlManager::FilesMap & plantumlFiles,
const PlantumlManager::ContentMap & plantumlContent,
PlantumlManager::OutputFormat format )
static

Definition at line 241 of file plantuml.cpp.

244{
245 /* example : running: java -Djava.awt.headless=true
246 -jar "/usr/local/bin/plantuml.jar"
247 -o "test_doxygen/DOXYGEN_OUTPUT/html"
248 -tpng
249 "test_doxygen/DOXYGEN_OUTPUT/html/A.pu"
250 -charset UTF-8
251 outDir:test_doxygen/DOXYGEN_OUTPUT/html
252 test_doxygen/DOXYGEN_OUTPUT/html/A
253 */
254 int exitCode = 0;
255 QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
256 QCString plantumlConfigFile = Config_getString(PLANTUML_CFG_FILE);
257
258 QCString pumlExe = "java";
259 QCString pumlArgs = "";
260 QCString pumlType = "";
261 QCString pumlOutDir = "";
262
263 const StringVector &pumlIncludePathList = Config_getList(PLANTUML_INCLUDE_PATH);
264 {
265 auto it = pumlIncludePathList.begin();
266 if (it!=pumlIncludePathList.end())
267 {
268 pumlArgs += "-Dplantuml.include.path=\"";
269 pumlArgs += it->c_str();
270 ++it;
271 }
272 while (it!=pumlIncludePathList.end())
273 {
274 pumlArgs += Portable::pathListSeparator();
275 pumlArgs += it->c_str();
276 ++it;
277 }
278 }
279 if (!pumlIncludePathList.empty()) pumlArgs += "\" ";
280 pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"\" ";
281 if (!plantumlConfigFile.isEmpty())
282 {
283 pumlArgs += "-config \"";
284 pumlArgs += plantumlConfigFile;
285 pumlArgs += "\" ";
286 }
287 // the -graphvizdot option expects a relative or absolute path to the dot executable, so
288 // we need to use the unverified DOT_PATH option and check if it points to an existing file.
289 QCString dotPath = Config_getString(DOT_PATH);
290 FileInfo dp(dotPath.str());
291 if (Config_getBool(HAVE_DOT) && dp.exists() && dp.isFile())
292 {
293 pumlArgs += "-graphvizdot \"";
294 pumlArgs += dotPath;
295 pumlArgs += "\" ";
296 }
297 switch (format)
298 {
300 pumlType="png";
301 break;
303 pumlType="eps";
304 break;
306 pumlType="svg";
307 break;
308 }
309
310 {
311 for (const auto &[name,nb] : plantumlContent)
312 {
313 if (nb.content.isEmpty()) continue;
314
315 QCString pumlArguments = pumlArgs;
316 msg("Generating PlantUML {} Files in {}\n",pumlType,name);
317 pumlArguments+="-o \"";
318 pumlArguments+=nb.outDir;
319 pumlArguments+="\" ";
320 pumlArguments+="-charset UTF-8 -t";
321 pumlArguments+=pumlType;
322 pumlArguments+=" ";
323
324 QCString puFileName("");
325 puFileName+=nb.outDir;
326 puFileName+="/";
327 pumlOutDir=puFileName;
328 puFileName+="inline_umlgraph_";
329 puFileName+=pumlType;
330 puFileName+=name.c_str();
331 puFileName+=".pu";
332
333 pumlArguments+="\"";
334 pumlArguments+=puFileName;
335 pumlArguments+="\" ";
336
337
338 QCString cachedContent;
339 FileInfo fi(puFileName.str());
340 if (fi.exists())
341 {
342 cachedContent = fileToString(puFileName);
343 }
344
345 std::ofstream file = Portable::openOutputStream(puFileName);
346 if (!file.is_open())
347 {
348 err_full(nb.srcFile,nb.srcLine,"Could not open file {} for writing",puFileName);
349 }
350 file.write( nb.content.data(), nb.content.length() );
351 file.close();
352 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::runPlantumlContent Running Plantuml arguments:{}\n",pumlArguments);
353
354 if (cachedContent == nb.content) continue;
355
356 if ((exitCode=Portable::system(pumlExe.data(),pumlArguments.data(),TRUE))!=0)
357 {
358 err_full(nb.srcFile,nb.srcLine,"Problems running PlantUML. Verify that the command 'java -jar \"{}\" -h' works from the command line. Exit code: {}.",
359 plantumlJarPath,exitCode);
360 }
361
362 if ( (format==PlantumlManager::PUML_EPS) && (Config_getBool(USE_PDFLATEX)) )
363 {
364 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::runPlantumlContent Running epstopdf\n");
365 auto files_kv = plantumlFiles.find(name);
366 if (files_kv!=plantumlFiles.end())
367 {
368 for (const auto &str : files_kv->second)
369 {
370 const int maxCmdLine = 40960;
372 epstopdfArgs.sprintf("\"%s%s.eps\" --outfile=\"%s%s.pdf\"",
373 pumlOutDir.data(),str.c_str(), pumlOutDir.data(),str.c_str());
374 if ((exitCode=Portable::system("epstopdf",epstopdfArgs.data()))!=0)
375 {
376 err_full(nb.srcFile,nb.srcLine,"Problems running epstopdf. Check your TeX installation! Exit code: {}.",exitCode);
377 }
378 else
379 {
380 Dir().remove(pumlOutDir.str()+str+".eps");
381 }
382 }
383 }
384 }
385 }
386 }
387}
Class representing a directory in the file system.
Definition dir.h:75
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:314
Minimal replacement for QFileInfo.
Definition fileinfo.h:23
This is an alternative implementation of QCString.
Definition qcstring.h:101
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
const std::string & str() const
Definition qcstring.h:537
@ ExplicitSize
Definition qcstring.h:133
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
#define Config_getList(name)
Definition config.h:38
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
static const int maxCmdLine
Definition dia.cpp:24
#define msg(fmt,...)
Definition message.h:94
#define err_full(file, line, fmt,...)
Definition message.h:132
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:665
QCString pathListSeparator()
Definition portable.cpp:400
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Definition portable.cpp:106
#define TRUE
Definition qcstring.h:37
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
Definition util.cpp:1442

References Config_getBool, Config_getList, Config_getString, QCString::data(), err_full, FileInfo::exists(), QCString::ExplicitSize, fileToString(), QCString::isEmpty(), FileInfo::isFile(), maxCmdLine, msg, Portable::openOutputStream(), Portable::pathListSeparator(), Debug::Plantuml, Debug::print(), PlantumlManager::PUML_BITMAP, PlantumlManager::PUML_EPS, PlantumlManager::PUML_SVG, Dir::remove(), QCString::sprintf(), QCString::str(), Portable::system(), and TRUE.

Referenced by PlantumlManager::run().

Variable Documentation

◆ g_PlantUmlMutex

std::mutex g_PlantUmlMutex
static

Definition at line 29 of file plantuml.cpp.

Referenced by PlantumlManager::generatePlantUmlFileNames().