Documenting a C Project with Doxygen

While analyzing the source code of the videogame Eat the Whistle, written in C, I had the need to build a dependency diagram of the files. There were over 60 .c files, so I wanted a file

I read about Doxygen, a documentation tool that is mainly used for C++ but that is also popular for C projects.

On this article, I explain how I installed and used it for Doxygen. The operating system I used was Ubuntu 25.10.

Installing Doxygen

Doxigen is a FOSS tool that is available through the official channel of the main Linux distros.

Graphviz is used by Doxigen to generated diagrams, so it is highly recommended.

I installed them from the terminal:

sudo apt install doxygen graphviz


Creating Doxygen file

Create the Doxygen configuration file by typing:

doxygen -g

Configuring Doxygen

PROJECT_NAME: Eat the Whistle

As I have split the files among src/ (.c files) and include/ (.h files), though the original arranged them in a different way, I should add the files as input.

INPUT: src include

Recursive is set to “NO”, as in this case there are no

RECURSIVE: NO

Latex is an output by default, but in my case, I’m only interested in HTML so I set it to no.

GENERATE_LATEX: Set to NO if you only want HTML.

OUTPUT_DIRECTORY = docs/doxyfile

OPTIMIZE_OUTPUT_C = YES

If you are using C, you may activate:

CALL_GRAPH = YES

CALLER_GRAPH = YES

When EXTRACT_ALL is set, even undocumented functions are displayed, though the warning about undocumented members are disabled.

EXTRACT_ALL = YES

I set SOURCE_BROWSER to be able to check the files from the browser.

SOURCE_BROWSER = YES

To allow interaction, we substituted png by the svg format:

DOT_IMAGE_FORMAT = svg

Then INTERACTIVE_SVG is set to “yes”:

INTERACTIVE_SVG = YES

Optionally, you can set GENERATE_LEGEND to yes to see the legend meaning:

GENERATE_LEGEND = YES

Editing source code files

I needed to add a header at least to the main file.

I added this to the entry file, i.e., etw.c:

/**
 * @file etw.c
 * @brief Entry point for the video game.
 */

I didn’t add any other comment to other files.

Generating documentation

I run this command from the germinal

doxygen Doxyfile

This generates an html/ directory within the folder I set, docs/. I can see the documentation by opening the file index.html.

Inside the file list, I could find the entry point file "etw.c", and the dependency diagram it had generated. So I got what I was looking for, without writing a single line of code.

Leave a Comment

Your email address will not be published. Required fields are marked *