Using Doxygen with graphviz—the Basics

This Web page provides streamlined instructions to create both html and LaTeX documentation for a basic C or C++ program or package. Thus, this page should be considered a guide to get started with Doxygen. Beyond these instructions, the Doxygen software system provides numerous features for generating software software that allow considerable tailoring of input and output. Overall, learning all options can require much time and effort, but this document can help you get started.

The Basic Steps for Using Doxygen with graphviz

Typically, production of basic documentation with Doxygen follows four steps:

  1. preparation of C/C++ files
  2. running Doxygen with the C/C++ files as input to produce html and .tex files as output
  3. running the LaTeX package on .tex files to create .pdf output
  4. adding graphics for calling diagrams, class hierarchies, and file dependencies.

File Preparation

As you write your C/C++ code, follow the the C/C++ Style Guide.

  1. Use the file extension ".h" for header files, ".c" for C code, ".cpp" for C++ code, and ".tcc" for C++ template files.

  2. To simplify the next steps with Doxygen, place all files for the current project in a separate directory. This directory should contain the .h, .c, .cpp and .tcc files for this software package, but no other files (e.g., no files for other projects). Later steps in these instructions will refer to this directory as the working directory.

    Note: Be sure that the actual file is placed in this directory; Doxygen may lose some functionality, if a symbolic link is in the working directory, rather than the file itself.

  3. Use /**, followed by whitespace, at the start of a comment preceding a function, and use */ at the end of the comment.

  4. Within a comment (starting with /**),

Although the Doxygen Manual on "Documenting the code" describes many more details that can refine the documentation, the elements listed above likely are adequate to get started.

Running Doxygen

  1. Open Doxygen. (On Mac OS X, this may involve using the Finder to click on the Doxygen.app within the Applications section.) When Doxygen opens a window or graphical interface, note several elements of the first screen:

The next steps in these instructions go through these elements step-by-step.

  1. Complete the first page on "Project" page in Doxygen's Wizard:

  2. Doxygen's next page clarifies the "Mode" for generating document.

  3. The next page identifies the type of output desired.

  4. The next page may identify the type of "diagrams to generate", although doxygen sometimes may skip this step.

  5. The "Run" screen appears next.

Generating a pdf file

Doxygen normally generates a directory labeled "latex", which contains numerous files in LaTeX format. These instructions assume that you have installed the LaTeX package for mathematical typesetting. If not, several free versions are available—try a Web search for "laTeX" and your type of computer (e.g., "latex Mac OS X" identifies the TexShop package that is widely available without cost).

  1. In a terminal window, go the "latex" directory, and check the file "refman.tex" is present. This is a "LaTeX" file, used by the LaTeX documentation system (a widely-used package designed for mathematical typesetting).

  2. Typing in the "latex" directory within the terminal window, generate a .pdf document with the command:

          make
        

    The pdf document "refman.pdf" should contain the full documentation.

Adding graphics for calling diagrams, class hierarchies, and file dependencies

Using the Doxygen, the fourth step using the wizard involves Diagrams. Within the "Diagrams" section,

At this point, all graphical options will be set.

With this option, moving to the "Run" tab allows one to click "Run doxygen" as before.

  1. If this process runs smoothly, with no error reported, then the full documentation is ready, and nothing more need be done.

  2. If "Run doxygen" generates an error to the effect, "dot not found", the underlying issue often is that doxygen cannot find the graphviz package, even if graphviz is installed. This issue is resolved as follows:

Documentation for Further Study