Permalink
Browse files

Added support for directory dependency graphs to template engine

  • Loading branch information...
Dimitri van Heesch
Dimitri van Heesch committed Aug 28, 2015
1 parent 43a0883 commit abe254fbe2235f5b913653acd076d2acd579d5e1
Showing with 119 additions and 23 deletions.
  1. +91 −5 src/context.cpp
  2. +2 −7 src/dirdef.cpp
  3. +0 −1 src/dirdef.h
  4. +12 −6 src/dot.cpp
  5. +2 −3 src/dot.h
  6. +12 −1 templates/html/htmldir.tpl
@@ -456,6 +456,18 @@ class TranslateContext::Private : public PropertyMapper
}
return TemplateVariant();
}
TemplateVariant handleDirDependencyGraphFor(const QValueList<TemplateVariant> &args) const
{
if (args.count()==1)
{
return theTranslator->trDirDepGraph(args[0].toString());
}
else
{
err("tr.dirDependencyGraphFor should take one argument, got %d!\n",args.count());
}
return TemplateVariant();
}
TemplateVariant handleInheritsList(const QValueList<TemplateVariant> &args) const
{
if (args.count()==1)
@@ -571,6 +583,10 @@ class TranslateContext::Private : public PropertyMapper
{
return TemplateVariant::Delegate::fromMethod<Private,&Private::handleCollaborationDiagramFor>(this);
}
TemplateVariant dirDependencyGraphFor() const
{
return TemplateVariant::Delegate::fromMethod<Private,&Private::handleDirDependencyGraphFor>(this);
}
TemplateVariant search() const
{
return theTranslator->trSearch();
@@ -1138,6 +1154,8 @@ class TranslateContext::Private : public PropertyMapper
addProperty("panelSyncOn", this,&Private::panelSyncOn);
//%% string panelSyncOff
addProperty("panelSyncOff", this,&Private::panelSyncOff);
//%% string dirDependencyGraph
addProperty("dirDependencyGraphFor", this,&Private::dirDependencyGraphFor);
m_javaOpt = Config_getBool("OPTIMIZE_OUTPUT_JAVA");
m_fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
@@ -1819,6 +1837,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
err("context.cpp: output format not yet supported");
break;
}
g_globals.dynSectionId++;
}
else if (classDiagrams)
{
@@ -1850,8 +1869,8 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
err("context.cpp: output format not yet supported");
break;
}
g_globals.dynSectionId++;
}
g_globals.dynSectionId++;
return TemplateVariant(result.data(),TRUE);
}
DotClassGraph *getCollaborationGraph() const
@@ -1900,8 +1919,8 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
err("context.cpp: output format not yet supported");
break;
}
g_globals.dynSectionId++;
}
g_globals.dynSectionId++;
return TemplateVariant(result.data(),TRUE);
}
@@ -2794,8 +2813,8 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
err("context.cpp: output format not yet supported");
break;
}
g_globals.dynSectionId++;
}
g_globals.dynSectionId++;
return TemplateVariant(result.data(),TRUE);
}
DotInclDepGraph *getIncludedByGraph() const
@@ -2845,8 +2864,8 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
err("context.cpp: output format not yet supported");
break;
}
g_globals.dynSectionId++;
}
g_globals.dynSectionId++;
return TemplateVariant(result.data(),TRUE);
}
TemplateVariant hasDetails() const
@@ -3109,6 +3128,8 @@ class DirContext::Private : public DefinitionContext<DirContext::Private>
addProperty("dirs", this,&Private::dirs);
addProperty("files", this,&Private::files);
addProperty("hasDetails", this,&Private::hasDetails);
addProperty("hasDirGraph", this,&Private::hasDirGraph);
addProperty("dirGraph", this,&Private::dirGraph);
addProperty("compoundType", this,&Private::compoundType);
}
virtual ~Private() {}
@@ -3176,6 +3197,70 @@ class DirContext::Private : public DefinitionContext<DirContext::Private>
{
return "";
}
DotDirDeps *getDirDepsGraph() const
{
if (!m_cache.dirDepsGraph)
{
m_cache.dirDepsGraph.reset(new DotDirDeps(m_dirDef));
}
return m_cache.dirDepsGraph.get();
}
TemplateVariant hasDirGraph() const
{
bool result=FALSE;
static bool haveDot = Config_getBool("HAVE_DOT");
static bool dirGraph = Config_getBool("DIRECTORY_GRAPH");
if (haveDot && dirGraph)
{
DotDirDeps *graph = getDirDepsGraph();
result = !graph->isTrivial();
}
return result;
}
TemplateVariant dirGraph() const
{
QGString result;
static bool haveDot = Config_getBool("HAVE_DOT");
static bool dirGraph = Config_getBool("DIRECTORY_GRAPH");
if (haveDot && dirGraph)
{
DotDirDeps *graph = getDirDepsGraph();
FTextStream t(&result);
switch (g_globals.outputFormat)
{
case ContextOutputFormat_Html:
{
graph->writeGraph(t,GOF_BITMAP,
EOF_Html,
g_globals.outputDir,
g_globals.outputDir+portable_pathSeparator()+m_dirDef->getOutputFileBase()+Doxygen::htmlFileExtension,
relPathAsString(),
TRUE,
g_globals.dynSectionId,
FALSE);
}
break;
case ContextOutputFormat_Latex:
{
graph->writeGraph(t,GOF_EPS,
EOF_LaTeX,
g_globals.outputDir,
g_globals.outputDir+portable_pathSeparator()+m_dirDef->getOutputFileBase()+".tex",
relPathAsString(),
TRUE,
g_globals.dynSectionId,
FALSE);
}
break;
// TODO: support other generators
default:
err("context.cpp: output format not yet supported");
break;
}
g_globals.dynSectionId++;
}
return TemplateVariant(result.data(),TRUE);
}
private:
DirDef *m_dirDef;
@@ -3184,6 +3269,7 @@ class DirContext::Private : public DefinitionContext<DirContext::Private>
Cachable() {}
SharedPtr<TemplateList> dirs;
SharedPtr<TemplateList> files;
ScopedPtr<DotDirDeps> dirDepsGraph;
};
mutable Cachable m_cache;
};
@@ -4687,8 +4773,8 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private>
err("context.cpp: output format not yet supported");
break;
}
g_globals.dynSectionId++;
}
g_globals.dynSectionId++;
return TemplateVariant(result.data(),TRUE);
}
TemplateVariant hasDetails() const
@@ -385,7 +385,7 @@ void DirDef::writeDocumentation(OutputList &ol)
ol.pushGeneratorState();
QCString title=theTranslator->trDirReference(m_dispName);
startFile(ol,getOutputFileBase(),name(),title,HLI_None,!generateTreeView);
startFile(ol,getOutputFileBase(),name(),title,HLI_Files,!generateTreeView);
if (!generateTreeView)
{
@@ -610,7 +610,7 @@ bool DirDef::isParentOf(DirDef *dir) const
bool DirDef::depGraphIsTrivial() const
{
return FALSE;
return m_usedDirs->count()==0;
}
//----------------------------------------------------------------------
@@ -696,11 +696,6 @@ DirDef *DirDef::mergeDirectoryInTree(const QCString &path)
return dir;
}
void DirDef::writeDepGraph(FTextStream &t)
{
writeDotDirDepGraph(t,this);
}
//----------------------------------------------------------------------
static void writePartialDirPath(OutputList &ol,const DirDef *root,const DirDef *target)
@@ -71,7 +71,6 @@ class DirDef : public Definition
// generate output
void writeDocumentation(OutputList &ol);
void writeDepGraph(FTextStream &t);
void writeTagFile(FTextStream &t);
static DirDef *mergeDirectoryInTree(const QCString &path);
@@ -3965,6 +3965,7 @@ bool DotCallGraph::isTooBig() const
}
//-------------------------------------------------------------
static void writeDotDirDepGraph(FTextStream &t,DirDef *dd,bool linkRelations);
DotDirDeps::DotDirDeps(DirDef *dir) : m_dir(dir)
{
@@ -3981,7 +3982,8 @@ QCString DotDirDeps::writeGraph(FTextStream &out,
const char *fileName,
const char *relPath,
bool generateImageMap,
int graphId) const
int graphId,
bool linkRelations) const
{
QDir d(path);
// store the original directory
@@ -4006,7 +4008,8 @@ QCString DotDirDeps::writeGraph(FTextStream &out,
// compute md5 checksum of the graph were are about to generate
QGString theGraph;
FTextStream md5stream(&theGraph);
m_dir->writeDepGraph(md5stream);
//m_dir->writeDepGraph(md5stream);
writeDotDirDepGraph(md5stream,m_dir,linkRelations);
uchar md5_sig[16];
QCString sigStr(33);
MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig);
@@ -4764,7 +4767,7 @@ void DotGroupCollaboration::writeGraphHeader(FTextStream &t,
t << " rankdir=LR;\n";
}
void writeDotDirDepGraph(FTextStream &t,DirDef *dd)
void writeDotDirDepGraph(FTextStream &t,DirDef *dd,bool linkRelations)
{
t << "digraph \"" << dd->displayName() << "\" {\n";
if (Config_getBool("DOT_TRANSPARENT"))
@@ -4896,11 +4899,14 @@ void writeDotDirDepGraph(FTextStream &t,DirDef *dd)
new DirRelation(relationName,dir,udir));
}
int nrefs = udir->filePairs().count();
t << " " << dir->getOutputFileBase() << "->"
t << " " << dir->getOutputFileBase() << "->"
<< usedDir->getOutputFileBase();
t << " [headlabel=\"" << nrefs << "\", labeldistance=1.5";
t << " headhref=\"" << relationName << Doxygen::htmlFileExtension
<< "\"];\n";
if (linkRelations)
{
t << " headhref=\"" << relationName << Doxygen::htmlFileExtension << "\"";
}
t << "];\n";
}
}
}
@@ -262,7 +262,8 @@ class DotDirDeps
const char *fileName,
const char *relPath,
bool writeImageMap=TRUE,
int graphId=-1) const;
int graphId=-1,
bool linkRelations=TRUE) const;
private:
DirDef *m_dir;
};
@@ -459,6 +460,4 @@ void writeDotImageMapFromFile(FTextStream &t,
const QCString& relPath,const QCString& baseName,
const QCString& context,int graphId=-1);
void writeDotDirDepGraph(FTextStream &t,DirDef *dd);
#endif
@@ -45,7 +45,18 @@
{% endif %}
{% endif %}
{# dir graph #}
{# TODO #}
{% if compound.hasDirGraph %}
{% with obj=compound %}
{% include 'htmldynheader.tpl' %}
{% endwith %}
{{ tr.dirDependencyGraphFor:compound.dirName }}
</div>
{% with obj=compound %}
{% include 'htmldyncontents.tpl' %}
{% endwith %}
{{ compound.dirGraph }}
</div>
{% endif %}
{# member declarations #}
{# directories #}
{% with list=compound.dirs label='subdirs' title=tr.directories local=False %}

0 comments on commit abe254f

Please sign in to comment.