Doxygen
Loading...
Searching...
No Matches
plantuml.cpp File Reference
#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 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)
 

Function Documentation

◆ addPlantumlContent()

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

Definition at line 360 of file plantuml.cpp.

363{
364 auto kv = plantumlContent.find(key);
365 if (kv==plantumlContent.end())
366 {
367 kv = plantumlContent.emplace(key,PlantumlContent("",outDir,srcFile,srcLine)).first;
368 }
369 kv->second.content+=puContent;
370}

Referenced by PlantumlManager::insert().

◆ addPlantumlFiles()

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

Definition at line 349 of file plantuml.cpp.

351{
352 auto kv = plantumlFiles.find(key);
353 if (kv==plantumlFiles.end())
354 {
355 kv = plantumlFiles.emplace(key,StringVector()).first;
356 }
357 kv->second.push_back(value);
358}
std::vector< std::string > StringVector
Definition containers.h:33

Referenced by PlantumlManager::insert().

◆ print() [1/2]

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

Definition at line 337 of file plantuml.cpp.

338{
340 {
341 for (const auto &[key,content] : plantumlContent)
342 {
343 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Content PlantumlContent key: %s\n",key.c_str());
344 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Content:\n%s\n",content.content.data());
345 }
346 }
347}
@ Plantuml
Definition debug.h:38
static void print(DebugMask mask, int prio, const char *fmt,...)
Definition debug.cpp:81
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:135

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

◆ print() [2/2]

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

Definition at line 322 of file plantuml.cpp.

323{
325 {
326 for (const auto &[key,list] : plantumlFiles)
327 {
328 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Files PlantumlFiles key:%s size:%zu\n",key.c_str(),list.size());
329 for (const auto &s : list)
330 {
331 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print list:%s\n",s.c_str());
332 }
333 }
334 }
335}

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

Referenced by PlantumlManager::insert().

◆ runPlantumlContent()

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

Definition at line 166 of file plantuml.cpp.

169{
170 /* example : running: java -Djava.awt.headless=true
171 -jar "/usr/local/bin/plantuml.jar"
172 -o "test_doxygen/DOXYGEN_OUTPUT/html"
173 -tpng
174 "test_doxygen/DOXYGEN_OUTPUT/html/A.pu"
175 -charset UTF-8
176 outDir:test_doxygen/DOXYGEN_OUTPUT/html
177 test_doxygen/DOXYGEN_OUTPUT/html/A
178 */
179 int exitCode = 0;
180 QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
181 QCString plantumlConfigFile = Config_getString(PLANTUML_CFG_FILE);
182
183 QCString pumlExe = "java";
184 QCString pumlArgs = "";
185 QCString pumlType = "";
186 QCString pumlOutDir = "";
187
188 const StringVector &pumlIncludePathList = Config_getList(PLANTUML_INCLUDE_PATH);
189 {
190 auto it = pumlIncludePathList.begin();
191 if (it!=pumlIncludePathList.end())
192 {
193 pumlArgs += "-Dplantuml.include.path=\"";
194 pumlArgs += it->c_str();
195 ++it;
196 }
197 while (it!=pumlIncludePathList.end())
198 {
199 pumlArgs += Portable::pathListSeparator();
200 pumlArgs += it->c_str();
201 ++it;
202 }
203 }
204 if (!pumlIncludePathList.empty()) pumlArgs += "\" ";
205 pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"\" ";
206 if (!plantumlConfigFile.isEmpty())
207 {
208 pumlArgs += "-config \"";
209 pumlArgs += plantumlConfigFile;
210 pumlArgs += "\" ";
211 }
212 // the -graphvizdot option expects a relative or absolute path to the dot executable, so
213 // we need to use the unverified DOT_PATH option and check if it points to an existing file.
214 QCString dotPath = Config_getString(DOT_PATH);
215 FileInfo dp(dotPath.str());
216 if (Config_getBool(HAVE_DOT) && dp.exists() && dp.isFile())
217 {
218 pumlArgs += "-graphvizdot \"";
219 pumlArgs += dotPath;
220 pumlArgs += "\" ";
221 }
222 switch (format)
223 {
225 pumlType="png";
226 break;
228 pumlType="eps";
229 break;
231 pumlType="svg";
232 break;
233 }
234
235 {
236 for (const auto &[name,nb] : plantumlContent)
237 {
238 if (nb.content.isEmpty()) continue;
239
240 QCString pumlArguments = pumlArgs;
241 msg("Generating PlantUML %s Files in %s\n",qPrint(pumlType),name.c_str());
242 pumlArguments+="-o \"";
243 pumlArguments+=nb.outDir;
244 pumlArguments+="\" ";
245 pumlArguments+="-charset UTF-8 -t";
246 pumlArguments+=pumlType;
247 pumlArguments+=" ";
248
249 QCString puFileName("");
250 puFileName+=nb.outDir;
251 puFileName+="/";
252 pumlOutDir=puFileName;
253 puFileName+="inline_umlgraph_";
254 puFileName+=pumlType;
255 puFileName+=name.c_str();
256 puFileName+=".pu";
257
258 pumlArguments+="\"";
259 pumlArguments+=puFileName;
260 pumlArguments+="\" ";
261
262
263 QCString cachedContent;
264 FileInfo fi(puFileName.str());
265 if (fi.exists())
266 {
267 cachedContent = fileToString(puFileName);
268 }
269
270 std::ofstream file = Portable::openOutputStream(puFileName);
271 if (!file.is_open())
272 {
273 err_full(nb.srcFile,nb.srcLine,"Could not open file %s for writing",puFileName.data());
274 }
275 file.write( nb.content.data(), nb.content.length() );
276 file.close();
277 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::runPlantumlContent Running Plantuml arguments:%s\n",qPrint(pumlArguments));
278
279 if (cachedContent == nb.content) continue;
280
281 if ((exitCode=Portable::system(pumlExe.data(),pumlArguments.data(),TRUE))!=0)
282 {
283 err_full(nb.srcFile,nb.srcLine,"Problems running PlantUML. Verify that the command 'java -jar \"%s\" -h' works from the command line. Exit code: %d.",
284 plantumlJarPath.data(),exitCode);
285 }
286
287 if ( (format==PlantumlManager::PUML_EPS) && (Config_getBool(USE_PDFLATEX)) )
288 {
289 Debug::print(Debug::Plantuml,0,"*** %s Running epstopdf\n","PlantumlManager::runPlantumlContent");
290 auto files_kv = plantumlFiles.find(name);
291 if (files_kv!=plantumlFiles.end())
292 {
293 for (const auto &str : files_kv->second)
294 {
295 const int maxCmdLine = 40960;
297 epstopdfArgs.sprintf("\"%s%s.eps\" --outfile=\"%s%s.pdf\"",
298 pumlOutDir.data(),str.c_str(), pumlOutDir.data(),str.c_str());
299 if ((exitCode=Portable::system("epstopdf",epstopdfArgs.data()))!=0)
300 {
301 err_full(nb.srcFile,nb.srcLine,"Problems running epstopdf. Check your TeX installation! Exit code: %d.",exitCode);
302 }
303 else
304 {
305 Dir().remove(pumlOutDir.str()+str+".eps");
306 }
307 }
308 }
309 }
310 }
311 }
312}
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
void msg(const char *fmt,...)
Definition message.cpp:98
#define err_full(file, line, fmt,...)
Definition message.h:89
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
const char * qPrint(const char *s)
Definition qcstring.h:672
#define TRUE
Definition qcstring.h:37
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
Definition util.cpp:1414

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, qPrint(), Dir::remove(), QCString::sprintf(), QCString::str(), Portable::system(), and TRUE.

Referenced by PlantumlManager::run().