summaryrefslogtreecommitdiffstats
path: root/src/plantuml.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2019-01-08 20:53:01 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2019-01-08 20:59:07 (GMT)
commit5021481aac33e51a4d94f4fea0fc745b4cbc8004 (patch)
tree85c51b71268c29d0feacac36060f2fcf1b14adc6 /src/plantuml.cpp
parent5c30c470ff646081747c6e9735d17a62383152b4 (diff)
parent51bba9d513b22bd92d90127657b76f51d4555fa8 (diff)
downloadDoxygen-5021481aac33e51a4d94f4fea0fc745b4cbc8004.zip
Doxygen-5021481aac33e51a4d94f4fea0fc745b4cbc8004.tar.gz
Doxygen-5021481aac33e51a4d94f4fea0fc745b4cbc8004.tar.bz2
Merge branch 'run_java_once_3rd_trial' of https://github.com/cheoljoo/doxygen into cheoljoo-run_java_once_3rd_trial
Diffstat (limited to 'src/plantuml.cpp')
-rw-r--r--src/plantuml.cpp237
1 files changed, 109 insertions, 128 deletions
diff --git a/src/plantuml.cpp b/src/plantuml.cpp
index 794cd8a..6966100 100644
--- a/src/plantuml.cpp
+++ b/src/plantuml.cpp
@@ -14,6 +14,7 @@
*/
#include "plantuml.h"
+#include "util.h"
#include "portable.h"
#include "config.h"
#include "doxygen.h"
@@ -25,9 +26,8 @@
#include <qdict.h>
#include <qlist.h>
-static const int maxCmdLine = 40960;
-QCString writePlantUMLSource(const QCString &outDir,const QCString &fileName,const QCString &content,PlantUMLOutputFormat format)
+QCString PlantumlManager::writePlantUMLSource(const QCString &outDir,const QCString &fileName,const QCString &content,OutputFormat format)
{
QCString baseName;
QCString puName;
@@ -63,77 +63,31 @@ QCString writePlantUMLSource(const QCString &outDir,const QCString &fileName,con
imgName =puName+".svg";
break;
}
+
Debug::print(Debug::Plantuml,0,"*** %s baseName: %s\n","writePlantUMLSource",qPrint(baseName));
Debug::print(Debug::Plantuml,0,"*** %s puName: %s\n","writePlantUMLSource",qPrint(puName));
Debug::print(Debug::Plantuml,0,"*** %s imgName: %s\n","writePlantUMLSource",qPrint(imgName));
- QFile file(baseName+".pu");
- if (!file.open(IO_WriteOnly))
- {
- err("Could not open file %s for writing\n",baseName.data());
- }
QCString text = "@startuml "+imgName+"\n";
text+=content;
text+="\n@enduml\n";
- file.writeBlock( text, text.length() );
- file.close();
- //Debug::print(Debug::Plantuml,0,"*** %s baseFileName text: %s\n","writePlantUMLSource",qPrint(text));
- if (Config_getBool(PLANTUML_RUN_FAST))
- {
- QCString qcOutDir(outDir);
- uint pos = qcOutDir.findRev("/");
- QCString generateType(qcOutDir.right(qcOutDir.length() - (pos + 1)) );
- Debug::print(Debug::Plantuml,0,"*** %s generateType: %s\n","writePlantUMLSource",qPrint(generateType));
- PlantumlManager::instance()->insert(generateType,puName,format,text);
- }
+ QCString qcOutDir(outDir);
+ uint pos = qcOutDir.findRev("/");
+ QCString generateType(qcOutDir.right(qcOutDir.length() - (pos + 1)) );
+ Debug::print(Debug::Plantuml,0,"*** %s generateType: %s\n","writePlantUMLSource",qPrint(generateType));
+ PlantumlManager::instance()->insert(generateType,puName,format,text);
+ Debug::print(Debug::Plantuml,0,"*** %s generateType: %s\n","writePlantUMLSource",qPrint(generateType));
return baseName;
}
-void generatePlantUMLOutput(const char *baseName,const char *outDir,PlantUMLOutputFormat format)
+void PlantumlManager::generatePlantUMLOutput(const char *baseName,const char *outDir,OutputFormat format)
{
QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
QCString plantumlConfigFile = Config_getString(PLANTUML_CFG_FILE);
QCString dotPath = Config_getString(DOT_PATH);
- QCString pumlExe = "java";
- QCString pumlArgs = "";
-
- //printf("*** %s %s\n","generatePlantUMLOutput",baseName);
- QStrList &pumlIncludePathList = Config_getList(PLANTUML_INCLUDE_PATH);
- char *s=pumlIncludePathList.first();
- if (s)
- {
- pumlArgs += "-Dplantuml.include.path=\"";
- pumlArgs += s;
- s = pumlIncludePathList.next();
- }
- while (s)
- {
- pumlArgs += portable_pathListSeparator();
- pumlArgs += s;
- s = pumlIncludePathList.next();
- }
- if (pumlIncludePathList.first()) pumlArgs += "\" ";
- pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"plantuml.jar\" ";
- if (!plantumlConfigFile.isEmpty())
- {
- pumlArgs += "-config \"";
- pumlArgs += plantumlConfigFile;
- pumlArgs += "\" ";
- }
- if (Config_getBool(HAVE_DOT) && !dotPath.isEmpty())
- {
- pumlArgs += "-graphvizdot \"";
- pumlArgs += dotPath;
- pumlArgs += "dot";
- pumlArgs += portable_commandExtension();
- pumlArgs += "\" ";
- }
- pumlArgs+="-o \"";
- pumlArgs+=outDir;
- pumlArgs+="\" ";
QCString imgName = baseName;
// The basename contains path, we need to strip the path from the filename in order
// to create the image file name which should be included in the index.qhp (Qt help index file).
@@ -145,50 +99,16 @@ void generatePlantUMLOutput(const char *baseName,const char *outDir,PlantUMLOutp
switch (format)
{
case PUML_BITMAP:
- pumlArgs+="-tpng";
imgName+=".png";
break;
case PUML_EPS:
- pumlArgs+="-teps";
imgName+=".eps";
break;
case PUML_SVG:
- pumlArgs+="-tsvg";
imgName+=".svg";
break;
}
- pumlArgs+=" \"";
- pumlArgs+=baseName;
- pumlArgs+=".pu\" ";
- pumlArgs+="-charset UTF-8 ";
- int exitCode;
- msg("Running PlantUML on generated file %s.pu\n",baseName);
- if (!Config_getBool(PLANTUML_RUN_FAST))
- {
- portable_sysTimerStart();
- Debug::print(Debug::Plantuml,0,"*** running: %s %s outDir:%s %s\n",qPrint(pumlExe),qPrint(pumlArgs),outDir,baseName);
- if ((exitCode=portable_system(pumlExe,pumlArgs,TRUE))!=0)
- {
- err("Problems running PlantUML. Verify that the command 'java -jar \"%splantuml.jar\" -h' works from the command line. Exit code: %d\n",
- plantumlJarPath.data(),exitCode);
- }
- else if (Config_getBool(DOT_CLEANUP))
- {
- QFile(QCString(baseName)+".pu").remove();
- }
- portable_sysTimerStop();
- if (format==PUML_EPS && Config_getBool(USE_PDFLATEX))
- {
- QCString epstopdfArgs(maxCmdLine);
- epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",baseName,baseName);
- portable_sysTimerStart();
- if ((exitCode=portable_system("epstopdf",epstopdfArgs))!=0)
- {
- err("Problems running epstopdf. Check your TeX installation! Exit code: %d\n",exitCode);
- }
- portable_sysTimerStop();
- }
- }
+
Doxygen::indexList->addImageFile(imgName);
}
@@ -201,6 +121,20 @@ PlantumlManager *PlantumlManager::instance()
if (!m_theInstance)
{
m_theInstance = new PlantumlManager;
+ QCString outputFilename = Config_getString(OUTPUT_DIRECTORY) + "/" + CACHE_FILENAME;
+ QFileInfo fi(outputFilename);
+ if (fi.exists())
+ {
+ m_theInstance->m_cachedPlantumlAllContent = fileToString(outputFilename);
+ }
+ else
+ {
+ m_theInstance->m_cachedPlantumlAllContent = "";
+ }
+ Debug::print(Debug::Plantuml,0,"*** instance() : m_cachedPlantumlAllContent = [%s]\n",qPrint(m_theInstance->m_cachedPlantumlAllContent));
+ m_theInstance->m_pngPlantumlContent.clear();
+ m_theInstance->m_svgPlantumlContent.clear();
+ m_theInstance->m_epsPlantumlContent.clear();
}
return m_theInstance;
}
@@ -245,9 +179,16 @@ PlantumlManager::~PlantumlManager()
static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
const QDict< QCString > &plantumlContent,
- const char *type)
+ PlantumlManager::OutputFormat format)
{
- /* example : running: java -Djava.awt.headless=true -jar "/Users/cheoljoo/code/common_telltale/GP/Apps/Src/MgrTelltale/tools/plantuml.jar" -o "/Users/cheoljoo/Code/LG/test_doxygen/DOXYGEN_OUTPUT/html" -tpng "/Users/cheoljoo/Code/LG/test_doxygen/DOXYGEN_OUTPUT/html/A.pu" -charset UTF-8 outDir:/Users/cheoljoo/Code/LG/test_doxygen/DOXYGEN_OUTPUT/html /Users/cheoljoo/Code/LG/test_doxygen/DOXYGEN_OUTPUT/html/A
+ /* example : running: java -Djava.awt.headless=true
+ -jar "/usr/local/bin/plantuml.jar"
+ -o "test_doxygen/DOXYGEN_OUTPUT/html"
+ -tpng
+ "test_doxygen/DOXYGEN_OUTPUT/html/A.pu"
+ -charset UTF-8
+ outDir:test_doxygen/DOXYGEN_OUTPUT/html
+ test_doxygen/DOXYGEN_OUTPUT/html/A
*/
int exitCode;
QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
@@ -256,6 +197,8 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
QCString pumlExe = "java";
QCString pumlArgs = "";
+ QCString pumlType = "";
+ QCString pumlOutDir = "";
QStrList &pumlIncludePathList = Config_getList(PLANTUML_INCLUDE_PATH);
char *s=pumlIncludePathList.first();
@@ -263,13 +206,13 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
{
pumlArgs += "-Dplantuml.include.path=\"";
pumlArgs += s;
- s = pumlIncludePathList.next();
+ s = pumlIncludePathList.next();
}
while (s)
{
pumlArgs += portable_pathListSeparator();
pumlArgs += s;
- s = pumlIncludePathList.next();
+ s = pumlIncludePathList.next();
}
if (pumlIncludePathList.first()) pumlArgs += "\" ";
pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"plantuml.jar\" ";
@@ -287,6 +230,18 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
pumlArgs += portable_commandExtension();
pumlArgs += "\" ";
}
+ switch (format)
+ {
+ case PlantumlManager::PUML_BITMAP:
+ pumlType="png";
+ break;
+ case PlantumlManager::PUML_EPS:
+ pumlType="eps";
+ break;
+ case PlantumlManager::PUML_SVG:
+ pumlType="svg";
+ break;
+ }
{
QDictIterator< QCString > it( plantumlContent); // See QDictIterator
@@ -294,14 +249,14 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
for (it.toFirst();(nb=it.current());++it)
{
QCString pumlArguments(pumlArgs);
- msg("Running PlantUML on png plantumlFiles in %s\n",qPrint(it.currentKey()));
+ msg("Generating PlantUML %s Files in %s\n",qPrint(pumlType),qPrint(it.currentKey()));
pumlArguments+="-o \"";
pumlArguments+=Config_getString(OUTPUT_DIRECTORY);
pumlArguments+="/";
pumlArguments+=it.currentKey();
pumlArguments+="\" ";
pumlArguments+="-charset UTF-8 -t";
- pumlArguments+=type;
+ pumlArguments+=pumlType;
pumlArguments+=" ";
QCString puFileName("");
@@ -309,8 +264,9 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
puFileName+="/";
puFileName+=it.currentKey();
puFileName+="/";
+ pumlOutDir=puFileName;
puFileName+="inline_umlgraph_";
- puFileName+=type;
+ puFileName+=pumlType;
puFileName+=it.currentKey();
puFileName+=".pu";
@@ -326,6 +282,8 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
file.writeBlock( *nb, nb->length() );
file.close();
Debug::print(Debug::Plantuml,0,"*** %s Running Plantuml arguments:%s\n","PlantumlManager::runPlantumlContent",qPrint(pumlArguments));
+
+ portable_sysTimerStart();
if ((exitCode=portable_system(pumlExe,pumlArguments,TRUE))!=0)
{
err("Problems running PlantUML. Verify that the command 'java -jar \"%splantuml.jar\" -h' works from the command line. Exit code: %d\n",
@@ -333,36 +291,53 @@ static void runPlantumlContent(const QDict< QList <QCString> > &plantumlFiles,
}
else if (Config_getBool(DOT_CLEANUP))
{
+ Debug::print(Debug::Plantuml,0,"*** %s Remove %s file\n","PlantumlManager::runPlantumlContent",qPrint(puFileName));
file.remove();
}
- }
- }
+ portable_sysTimerStop();
- {
- QDictIterator< QList<QCString> > it( plantumlFiles); // See QDictIterator
- QList<QCString> *list;
- for (it.toFirst();(list=it.current());++it)
- {
- QListIterator<QCString> li(*list);
- QCString *nb;
- if (Config_getBool(DOT_CLEANUP))
+ if ( (format==PlantumlManager::PUML_EPS) && (Config_getBool(USE_PDFLATEX)) )
{
- for (li.toFirst();(nb=li.current());++li)
+ Debug::print(Debug::Plantuml,0,"*** %s Running epstopdf\n","PlantumlManager::runPlantumlContent");
+ QList<QCString> *list = plantumlFiles[it.currentKey()];
+ if (list)
{
- QCString pumlName = "";
- pumlName+=Config_getString(OUTPUT_DIRECTORY);
- pumlName+="/";
- pumlName+=it.currentKey();
- pumlName+="/";
- pumlName+=*nb;
- pumlName+=".pu";
- QFile(pumlName).remove();
+ QListIterator<QCString> li(*list);
+ QCString *nb;
+ for (li.toFirst();(nb=li.current());++li)
+ {
+ const int maxCmdLine = 40960;
+ QCString epstopdfArgs(maxCmdLine);
+ epstopdfArgs.sprintf("\"%s%s.eps\" --outfile=\"%s%s.pdf\"",qPrint(pumlOutDir),qPrint(*nb),qPrint(pumlOutDir),qPrint(*nb));
+ portable_sysTimerStart();
+ if ((exitCode=portable_system("epstopdf",epstopdfArgs))!=0)
+ {
+ err("Problems running epstopdf. Check your TeX installation! Exit code: %d\n",exitCode);
+ }
+ portable_sysTimerStop();
+ }
}
}
}
}
}
+void PlantumlManager::run()
+{
+ Debug::print(Debug::Plantuml,0,"*** %s\n","PlantumlManager::run");
+ runPlantumlContent(m_pngPlantumlFiles, m_pngPlantumlContent, PUML_BITMAP);
+ runPlantumlContent(m_svgPlantumlFiles, m_svgPlantumlContent, PUML_SVG);
+ runPlantumlContent(m_epsPlantumlFiles, m_epsPlantumlContent, PUML_EPS);
+ QCString outputFilename = Config_getString(OUTPUT_DIRECTORY) + "/" + CACHE_FILENAME;
+ QFile file(outputFilename);
+ if (!file.open(IO_WriteOnly))
+ {
+ err("Could not open file %s for writing\n",CACHE_FILENAME);
+ }
+ file.writeBlock( m_currentPlantumlAllContent, m_currentPlantumlAllContent.length() );
+ file.close();
+}
+
static void print(const QDict< QList <QCString> > &plantumlFiles)
{
if (Debug::isFlagSet(Debug::Plantuml))
@@ -371,7 +346,7 @@ static void print(const QDict< QList <QCString> > &plantumlFiles)
QList<QCString> *list;
for (it.toFirst();(list=it.current());++it)
{
- Debug::print(Debug::Plantuml,0,"*** %s PlantumlFiles key:%s\n","PlantumlManager::print",qPrint(it.currentKey()));
+ Debug::print(Debug::Plantuml,0,"*** %s PlantumlFiles key:%s size:%d\n","PlantumlManager::print Files",qPrint(it.currentKey()),(*list).count());
QListIterator<QCString> li(*list);
QCString *nb;
for (li.toFirst();(nb=li.current());++li)
@@ -390,7 +365,7 @@ static void print(const QDict<QCString> &plantumlContent)
QCString *nb;
for (it.toFirst();(nb=it.current());++it)
{
- Debug::print(Debug::Plantuml,0,"*** %s PlantumlContent key:%s\n","PlantumlManager::print",qPrint(it.currentKey()));
+ Debug::print(Debug::Plantuml,0,"*** %s PlantumlContent key:%s\n","PlantumlManager::print Content",qPrint(it.currentKey()));
Debug::print(Debug::Plantuml,0,"*** %s Content :%s\n","PlantumlManager::print",qPrint(*nb));
}
}
@@ -409,7 +384,7 @@ static void addPlantumlFiles(QDict< QList<QCString> > &plantumlFiles,
}
static void addPlantumlContent(QDict< QCString > &plantumlContent,
- const QCString &key, const QCString &puContent)
+ const QCString &key, const QCString &puContent)
{
QCString* content = plantumlContent.find(key);
if (content == 0)
@@ -420,18 +395,24 @@ static void addPlantumlContent(QDict< QCString > &plantumlContent,
(*content)+=puContent;
}
-void PlantumlManager::run()
-{
- Debug::print(Debug::Plantuml,0,"*** %s\n","PlantumlManager::run");
- runPlantumlContent(m_pngPlantumlFiles, m_pngPlantumlContent, "png");
- runPlantumlContent(m_svgPlantumlFiles, m_svgPlantumlContent, "svg");
- runPlantumlContent(m_epsPlantumlFiles, m_epsPlantumlContent, "eps");
-}
+
void PlantumlManager::insert(const QCString &key, const QCString &value,
- PlantUMLOutputFormat format,const QCString &puContent)
+ OutputFormat format,const QCString &puContent)
{
+ int find;
+
Debug::print(Debug::Plantuml,0,"*** %s key:%s ,value:%s\n","PlantumlManager::insert",qPrint(key),qPrint(value));
+
+ m_currentPlantumlAllContent+=puContent;
+
+ find = m_cachedPlantumlAllContent.find(puContent);
+ Debug::print(Debug::Plantuml,0,"*** %s find: %d\n","PlantumlManager::addPlantumlContent",find);
+ if (find >=0)
+ { // matched in cache. so we skip to run java for this plantuml
+ return ;
+ }
+
switch (format)
{
case PUML_BITMAP: