Automatically generate documentation from source code using doxygen

If  you are an open source developer then you would have seen doxygen generated documentation somewhere along your work.Doxygen supports a number of languages like C,C++,PHP,Python,Java etc.Using doxygen, you can auto-generate API reference documentation of source code, in HTML or Latex format. You can also visualize class dependency and the relationship between different source files.

To install doxygen

sudo apt-get install doxygen
sudo apt-get install graphviz

Now to view doxygen in action if you have source files use it else download this

wget http://curl.haxx.se/libcurl/c/allexamples.zip

unzip allexamples.zip

cd allexamples

Now create a doxygen configuration file

doxygen -g my_proj.conf

Screenshot from 2014-01-08 07:58:51

Now edit the configuration file and change some options as shown below

# document all entities in the project.
EXTRACT_ALL            = YES

# document all static members of a file.
EXTRACT_STATIC         = YES

# specify the root directory that contains the project's source files.
INPUT                  = /home/ganesh/Desktop/allexamples

# search sub-directories for all source files.
RECURSIVE              = YES

# include the body of functions and classes in the documentation.
INLINE_SOURCES         = YES

# generate visualization graph by using dot program (part of graphviz package).
HAVE_DOT               = YES

CALL_GRAPH             = YES
CALLER_GRAPH           = YES

Please not that INPUT variable must contain your path

Now run doxygen to generate documentation

doxygen my_proj.conf

Now two folders html and latex will be created inside our source code folder

cd html

find index.html and open it in browser you can see documentation.In files tab if you click on a file you can see plotting

Screenshot from 2014-01-08 08:14:04

 

Screenshot from 2014-01-08 08:14:23

 

 

Happy Hacking 🙂

Advertisements