A script to generate a Doxyfile with call graphs , it needs to have installed doxygen and graphviz
Ensure you have the required dependencies installed:
- Graphviz: Used for generating graphs.
# Example installation on Debian-based systems
sudo apt-get install graphviz
./makeDoxy.sh -i "main.c src" -e "libft"
Explanation
-i or --input: Specify input directories/files for Doxygen.
-e or --exclude: Specify directories/files to be excluded from Doxygen.
Generated Output
The script generates Doxygen documentation with configured settings. View the generated documentation for details on your project's structure and relationships.
#!/bin/bash
# Generate Doxygen configuration file
doxygen -g
# Replace specific lines in the Doxygen configuration file to create the call graphs
sed -i 's/HAVE_DOT\s*=\s*NO/HAVE_DOT = YES/' Doxyfile
sed -i 's/EXTRACT_ALL\s*=\s*NO/EXTRACT_ALL = YES/' Doxyfile
sed -i 's/EXTRACT_PRIVATE\s*=\s*NO/EXTRACT_PRIVATE = YES/' Doxyfile
sed -i 's/EXTRACT_STATIC\s*=\s*NO/EXTRACT_STATIC = YES/' Doxyfile
sed -i 's/CALL_GRAPH\s*=\s*NO/CALL_GRAPH = YES/' Doxyfile
sed -i 's/CALLER_GRAPH\s*=\s*NO/CALLER_GRAPH = YES/' Doxyfile
sed -i 's/DISABLE_INDEX\s*=\s*NO/DISABLE_INDEX = YES/' Doxyfile
sed -i 's/GENERATE_TREEVIEW\s*=\s*NO/GENERATE_TREEVIEW = YES/' Doxyfile
sed -i 's/RECURSIVE\s*=\s*NO/RECURSIVE = YES/' Doxyfile
sed -i 's/INLINE_SOURCES\s*=\s*NO/INLINE_SOURCES = YES/' Doxyfile
while [[ $# -gt 0 ]]
do
case "$1" in
-i|--input)
INPUT="$2"
shift 2
;;
-e|--exclude)
EXCLUDE="$2"
shift 2
;;
*)
shift
;;
esac
done
sed -i "s/INPUT\s*=\s*/INPUT = $INPUT/" Doxyfile
sed -i "s/EXCLUDE\s*=\s*/EXCLUDE = $EXCLUDE/" Doxyfile
echo " INPUT = $INPUT "
echo " EXCLUDE = $EXCLUDE "
doxygen Doxyfile
Make it executable with :
chmod +x ./doxyGraph.sh
And thats it, after you can open the file with a browser
brave html/main_foo.html
Original idea from https://stackoverflow.com/a/68342053
if you write your comments in this format , Doxygen will generate a nice documentation for every function. There are more attributes that you can set and looks really good in the docs
/**
* @brief Description that tells what the function after this comment does
*
* @param[in] ac The argument count
* @param av The argument vector (array of strings)
*
* @return what does it return
*/