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 "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)
 

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 361 of file plantuml.cpp.

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

Referenced by PlantumlManager::insert().

◆ addPlantumlFiles()

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

Definition at line 350 of file plantuml.cpp.

352{
353 auto kv = plantumlFiles.find(key);
354 if (kv==plantumlFiles.end())
355 {
356 kv = plantumlFiles.emplace(key,StringVector()).first;
357 }
358 kv->second.push_back(value);
359}
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 338 of file plantuml.cpp.

339{
341 {
342 for (const auto &[key,content] : plantumlContent)
343 {
344 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Content PlantumlContent key: {}\n",key);
345 Debug::print(Debug::Plantuml,0,"*** PlantumlManager::print Content:\n{}\n",content.content);
346 }
347 }
348}
@ 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]

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

Definition at line 323 of file plantuml.cpp.

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

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 167 of file plantuml.cpp.

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

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().