Hi there,
There was a post on the doxygen-users list a few days ago asking if it is
possible to do something like the following:
/** blah blah
\dot
graph G {
a -- b
#if defined(ENABLE_C)
b -- c
c -- a
#endif
}
\enddot
*/
Basically this allows showing or hiding of nodes based on the pre-processor
defines. As far as I've been able to workout, this cannot be done without
invoking an external pre-processor as part of a build step or script.
This feature is something I very much want, as I have a large diagram with a
few small parts which are optional depending on compile switches. DOT
itself seems to like the idea of pre-processing as it ignores any lines that
start with a # character, so is safe to ignore and '#line' output, were the
pre-processor to make any.
There follows a patch that adds an option "PREPROCESS_DOT_FILES" to allow
DOT input files to be preprocessed. I would be very grateful to know if
this patch can be included in a future version or Doxygen, or whether it
needs any changes to be acceptable.
The patch can be applied in the following way:
$ tar -xzf doxygen-1.4.3.src.tar.gz
$ cd doxygen-1.4.3
$ patch -p1 < patchfile
Here is the patch:
diff -Naurw doxygen-1.4.3.orig/addon/doxywizard/config.l
doxygen-1.4.3/addon/doxywizard/config.l
--- doxygen-1.4.3.orig/addon/doxywizard/config.l 2005-05-16
20:38:16.000000000 +0100
+++ doxygen-1.4.3/addon/doxywizard/config.l 2005-05-24
22:57:11.358347200 +0100
@@ -2491,6 +2491,16 @@
TRUE
);
cb->addDependency("ENABLE_PREPROCESSING");
+ cb = addBool(
+ "PREPROCESS_DOT_FILES",
+ "If the PREPROCESS_DOT_FILES tag is set to YES then
doxygen's preprocessor \n"
+ "will be called on all files that are about to be
passed to DOT. This \n"
+ "allows pre-processor protections to be added around
nodes such that build \n"
+ "defines can add or hide graph nodes. The default
option is NO such that \n"
+ "compatibility with older versions of Doxygen is
maintained. \n",
+ FALSE
+ );
+ cb->addDependency("ENABLE_PREPROCESSING");
//--------------------------------------------------------------------------
---------------------
addInfo( "External","Configuration::additions related to external
references ");
//--------------------------------------------------------------------------
---------------------
diff -Naurw doxygen-1.4.3.orig/src/config.l doxygen-1.4.3/src/config.l
--- doxygen-1.4.3.orig/src/config.l 2005-05-12 20:19:42.000000000 +0100
+++ doxygen-1.4.3/src/config.l 2005-05-24 22:56:52.050584000 +0100
@@ -2491,6 +2491,16 @@
TRUE
);
cb->addDependency("ENABLE_PREPROCESSING");
+ cb = addBool(
+ "PREPROCESS_DOT_FILES",
+ "If the PREPROCESS_DOT_FILES tag is set to YES then
doxygen's preprocessor \n"
+ "will be called on all files that are about to be
passed to DOT. This \n"
+ "allows pre-processor protections to be added around
nodes such that build \n"
+ "defines can add or hide graph nodes. The default
option is NO such that \n"
+ "compatibility with older versions of Doxygen is
maintained. \n",
+ FALSE
+ );
+ cb->addDependency("ENABLE_PREPROCESSING");
//--------------------------------------------------------------------------
---------------------
addInfo( "External","Configuration::additions related to external
references ");
//--------------------------------------------------------------------------
---------------------
diff -Naurw doxygen-1.4.3.orig/src/dot.cpp doxygen-1.4.3/src/dot.cpp
--- doxygen-1.4.3.orig/src/dot.cpp 2005-04-17 17:55:56.000000000 +0100
+++ doxygen-1.4.3/src/dot.cpp 2005-05-24 23:44:22.929947200 +0100
@@ -29,6 +29,8 @@
#include "docparser.h"
#include "debug.h"
#include "pagedef.h"
+#include "pre.h"
+#include "bufstr.h"
#include <qdir.h>
#include <qfile.h>
@@ -2714,6 +2716,24 @@
#endif
absOutFile+=outFile;
+ // Preprocess the file if needed */
+ if(Config_getBool("PREPROCESS_DOT_FILES"))
+ {
+ BufStr ppBuf(512);
+
+ preprocessFile(inFile, ppBuf);
+
+ // Rewrite the buffer to the input file
+ QFile file(inFile);
+ if (!file.open(IO_WriteOnly))
+ {
+ err("Could not open file %s for writing\n",inFile);
+ }
+ file.writeBlock( ppBuf.data(), ppBuf.curPos() );
+ file.close();
+ }
+
+
// chdir to the output dir, so dot can find the font file.
QCString oldDir = convertToQCString(QDir::currentDirPath());
// go to the html output directory (i.e. path)
Cheers,
Mike
|