Skip to content

Commit

Permalink
More flexible directory graphs regarding show / hide
Browse files Browse the repository at this point in the history
For call / caller / include / included by graphs it is possible to steer the graph creation process on a 1 to 1 base (commands like \callgraph and \hidecallgraph).

Introducing for the directory graphs:
```
    \directorygraph and \hidedirectorygraph
```
  • Loading branch information
albert-github committed Aug 20, 2023
1 parent e55d17e commit 9f51089
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 9 deletions.
28 changes: 28 additions & 0 deletions doc/commands.doc
Expand Up @@ -73,6 +73,7 @@ documentation:
\refitem cmddetails \\details
\refitem cmddiafile \\diafile
\refitem cmddir \\dir
\refitem cmddirectorygraph \\directorygraph
\refitem cmddocbookinclude \\docbookinclude
\refitem cmddocbookonly \\docbookonly
\refitem cmddontinclude \\dontinclude
Expand Down Expand Up @@ -118,6 +119,7 @@ documentation:
\refitem cmdheaderfile \\headerfile
\refitem cmdhidecallergraph \\hidecallergraph
\refitem cmdhidecallgraph \\hidecallgraph
\refitem cmdhidedirectorygraph \\hidedirectorygraph
\refitem cmdhideincludedbygraph \\hideincludedbygraph
\refitem cmdhideincludegraph \\hideincludegraph
\refitem cmdhiderefby \\hiderefby
Expand Down Expand Up @@ -487,6 +489,32 @@ Structural indicators
section \ref cmdhideincludegraph "\\hideincludegraph" and
option \ref cfg_included_by_graph "INCLUDED_BY_GRAPH"

<hr>
\section cmddirectorygraph \\directorygraph

\addindex \\directorygraph
When this command is put in a comment block of a directory
(see section \ref cmddir "\\dir")
then doxygen will generate a directory graph for that directory. The
directory graph will be generated regardless of the value of
\ref cfg_directory_graph "DIRECTORY_GRAPH".

\sa section \ref cmdhidedirectorygraph "\\hidedirectorygraph",
option \ref cfg_directory_graph "DIRECTORY_GRAPH"

<hr>
\section cmdhidedirectorygraph \\hidedirectorygraph

\addindex \\hidedirectorygraph
When this command is put in a comment block of a directory
(see section \ref cmddir "\\dir")
then doxygen will not generate a directory graph for that directory. The
directory graph will not be generated regardless of the value of
\ref cfg_directory_graph "DIRECTORY_GRAPH".

\sa section \ref cmddirectorygraph "\\directorygraph",
option \ref cfg_directory_graph "DIRECTORY_GRAPH"

<hr>
\section cmdqualifier \\qualifier <label> | "(text)"

Expand Down
18 changes: 18 additions & 0 deletions src/commentscan.l
Expand Up @@ -128,6 +128,8 @@ static bool handleIncludegraph(yyscan_t yyscanner,const QCString &, const String
static bool handleIncludedBygraph(yyscan_t yyscanner,const QCString &, const StringVector &);
static bool handleHideIncludegraph(yyscan_t yyscanner,const QCString &, const StringVector &);
static bool handleHideIncludedBygraph(yyscan_t yyscanner,const QCString &, const StringVector &);
static bool handleDirectoryGraph(yyscan_t yyscanner,const QCString &, const StringVector &);
static bool handleHideDirectoryGraph(yyscan_t yyscanner,const QCString &, const StringVector &);
static bool handleReferencedByRelation(yyscan_t yyscanner,const QCString &, const StringVector &);
static bool handleHideReferencedByRelation(yyscan_t yyscanner,const QCString &, const StringVector &);
static bool handleReferencesRelation(yyscan_t yyscanner,const QCString &, const StringVector &);
Expand Down Expand Up @@ -210,6 +212,7 @@ static const std::map< std::string, DocCmdMap > docCmdMap =
{ "deprecated", { &handleDeprecated, CommandSpacing::XRef }},
{ "details", { &handleDetails, CommandSpacing::Block }},
{ "dir", { &handleDir, CommandSpacing::Invisible }},
{ "directorygraph", { &handleDirectoryGraph, CommandSpacing::Invisible }},
{ "docbookinclude", { 0, CommandSpacing::Inline }},
{ "docbookonly", { &handleFormatBlock, CommandSpacing::Invisible }},
{ "dot", { &handleFormatBlock, CommandSpacing::Block }},
Expand All @@ -227,6 +230,7 @@ static const std::map< std::string, DocCmdMap > docCmdMap =
{ "headerfile", { &handleHeaderFile, CommandSpacing::Invisible }},
{ "hidecallergraph", { &handleHideCallergraph, CommandSpacing::Invisible }},
{ "hidecallgraph", { &handleHideCallgraph, CommandSpacing::Invisible }},
{ "hidedirectorygraph", { &handleHideDirectoryGraph, CommandSpacing::Invisible }},
{ "hideincludedbygraph", { &handleHideIncludedBygraph, CommandSpacing::Invisible }},
{ "hideincludegraph", { &handleHideIncludegraph, CommandSpacing::Invisible }},
{ "hideinitializer", { &handleHideInitializer, CommandSpacing::Invisible }},
Expand Down Expand Up @@ -3105,6 +3109,20 @@ static bool handleHideIncludedBygraph(yyscan_t yyscanner,const QCString &, const
return FALSE;
}

static bool handleDirectoryGraph(yyscan_t yyscanner,const QCString &, const StringVector &)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
yyextra->current->directoryGraph = TRUE; // ON
return FALSE;
}

static bool handleHideDirectoryGraph(yyscan_t yyscanner,const QCString &, const StringVector &)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
yyextra->current->directoryGraph = FALSE; // OFF
return FALSE;
}

static bool handleQualifier(yyscan_t yyscanner,const QCString &cmd, const StringVector &)
{
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
Expand Down
5 changes: 5 additions & 0 deletions src/config.xml
Expand Up @@ -3902,6 +3902,11 @@ UML notation for the relationships.
to \c YES then doxygen will show the dependencies a directory has on other directories
in a graphical way. The dependency relations are determined by the \c \#include
relations between the files in the directories.
Explicit enabling a directory graph, when \c DIRECTORY_GRAPH is set to \c NO, can be
accomplished by means of the command \ref cmddirectorygraph "\\directorygraph".
Disabling a directory graph can be accomplished by means of the command
\ref cmdhidedirectorygraph "\\hidedirectorygraph".
]]>
</docs>
</option>
Expand Down
21 changes: 18 additions & 3 deletions src/dirdef.cpp
Expand Up @@ -73,6 +73,9 @@ class DirDefImpl : public DefinitionMixin<DirDef>
const FileDef *dstFd,bool srcDirect, bool dstDirect) override;
virtual void computeDependencies() override;

virtual bool hasDirectoryGraph() const override;
virtual void enableDirectoryGraph(bool e) override;

public:
static DirDef *mergeDirectoryInTree(const QCString &path);

Expand All @@ -98,6 +101,7 @@ class DirDefImpl : public DefinitionMixin<DirDef>
int m_level;
DirDef *m_parent;
UsedDirLinkedMap m_usedDirs;
bool m_hasDirectoryGraph = false;
};

DirDef *createDirDef(const QCString &path)
Expand Down Expand Up @@ -134,6 +138,8 @@ DirDefImpl::DirDefImpl(const QCString &path) : DefinitionMixin(path,1,1,path)

m_level=-1;
m_parent=0;
m_hasDirectoryGraph=Config_getBool(DIRECTORY_GRAPH);

}

DirDefImpl::~DirDefImpl()
Expand Down Expand Up @@ -309,7 +315,7 @@ void DirDefImpl::writeBriefDescription(OutputList &ol)
void DirDefImpl::writeDirectoryGraph(OutputList &ol)
{
// write graph dependency graph
if (Config_getBool(DIRECTORY_GRAPH) && Config_getBool(HAVE_DOT))
if (Config_getBool(HAVE_DOT) && m_hasDirectoryGraph /*&& Config_getBool(DIRECTORY_GRAPH)*/)
{
DotDirDeps dirDep(this);
if (!dirDep.isTrivial())
Expand Down Expand Up @@ -781,7 +787,6 @@ bool DirDefImpl::depGraphIsTrivial() const
return m_usedDirs.empty() && m_parent==nullptr;
}


//----------------------------------------------------------------------

UsedDir::UsedDir(const DirDef *dir) :
Expand Down Expand Up @@ -867,6 +872,16 @@ DirDef *DirDefImpl::mergeDirectoryInTree(const QCString &path)
return dir;
}

void DirDefImpl::enableDirectoryGraph(bool e)
{
m_hasDirectoryGraph=e;
}

bool DirDefImpl::hasDirectoryGraph() const
{
return m_hasDirectoryGraph;
}

//----------------------------------------------------------------------

QCString FilePair::key(const FileDef *srcFd,const FileDef *dstFd)
Expand Down Expand Up @@ -1144,7 +1159,7 @@ void generateDirDocs(OutputList &ol)
dir->writeDocumentation(ol);
ol.popGeneratorState();
}
if (Config_getBool(DIRECTORY_GRAPH))
//if (Config_getBool(DIRECTORY_GRAPH))
{
for (const auto &dr : Doxygen::dirRelations)
{
Expand Down
4 changes: 4 additions & 0 deletions src/dirdef.h
Expand Up @@ -146,6 +146,10 @@ class DirDef : public DefinitionMutable, public Definition
virtual void addUsesDependency(const DirDef *usedDir,const FileDef *srcFd,
const FileDef *dstFd,bool srcDirect, bool dstDirect) = 0;
virtual void computeDependencies() = 0;

// directory graph related members
virtual bool hasDirectoryGraph() const = 0;
virtual void enableDirectoryGraph(bool e) = 0;
};

// --- Cast functions
Expand Down
10 changes: 4 additions & 6 deletions src/doxygen.cpp
Expand Up @@ -9110,6 +9110,7 @@ static void findDirDocumentation(const Entry *root)
matchingDir->setBriefDescription(root->brief,root->briefFile,root->briefLine);
matchingDir->setDocumentation(root->doc,root->docFile,root->docLine);
matchingDir->setRefItems(root->sli);
matchingDir->enableDirectoryGraph(root->directoryGraph);
addDirToGroups(root,matchingDir);
}
else
Expand Down Expand Up @@ -12292,12 +12293,9 @@ void parseInput()
setAnonymousEnumType();
g_s.end();

if (Config_getBool(DIRECTORY_GRAPH))
{
g_s.begin("Computing dependencies between directories...\n");
computeDirDependencies();
g_s.end();
}
g_s.begin("Computing dependencies between directories...\n");
computeDirDependencies();
g_s.end();

g_s.begin("Generating citations page...\n");
CitationManager::instance().generatePage();
Expand Down
3 changes: 3 additions & 0 deletions src/entry.cpp
Expand Up @@ -67,6 +67,7 @@ Entry::Entry(const Entry &e)
callerGraph = e.callerGraph;
includeGraph = e.includeGraph;
includedByGraph = e.includedByGraph;
directoryGraph = e.directoryGraph;
referencedByRelation = e.referencedByRelation;
referencesRelation = e.referencesRelation;
exported = e.exported;
Expand Down Expand Up @@ -192,6 +193,7 @@ void Entry::reset()
bool entryReferencesRelation = Config_getBool(REFERENCES_RELATION);
bool entryIncludeGraph = Config_getBool(INCLUDE_GRAPH);
bool entryIncludedByGraph = Config_getBool(INCLUDED_BY_GRAPH);
bool entryDirectoryGraph = Config_getBool(DIRECTORY_GRAPH);
//printf("Entry::reset()\n");
name.resize(0);
type.resize(0);
Expand Down Expand Up @@ -226,6 +228,7 @@ void Entry::reset()
callerGraph = entryCallerGraph;
includeGraph = entryIncludeGraph;
includedByGraph = entryIncludedByGraph;
directoryGraph = entryDirectoryGraph;
referencedByRelation = entryReferencedByRelation;
referencesRelation = entryReferencesRelation;
exported = false;
Expand Down
1 change: 1 addition & 0 deletions src/entry.h
Expand Up @@ -258,6 +258,7 @@ class Entry
bool referencesRelation; //!< do we need to show the references relation?
bool includeGraph; //!< do we need to draw the include graph?
bool includedByGraph; //!< do we need to draw the included by graph?
bool directoryGraph; //!< do we need to draw the directory graph?
bool exported; //!< is the symbol exported from a C++20 module
Specifier virt; //!< virtualness of the entry
QCString args; //!< member argument string
Expand Down

0 comments on commit 9f51089

Please sign in to comment.