Reputation: 21
I'm using Doxygen to document a MATLAB codebase. Doxygen doesn't support MATLAB natively, so I am using the m2cpp.pl
filter developed by Fabrice. The filter is good, but not good enough for Doxygen to automatically generate callgraphs and collaboration graphs. I have considered a few solutions.
Improve the filter
The most 'proper' option but unfortunately not worth my time. The filter is written in Perl, which I have almost no experience with. Moreover, I am documenting a legacy codebase that is unlikely to change and will soon be re-written in Python.
Manually write DOT
Doxygen generates diagrams by writing files in the DOT language, which are then rendered by Graphviz. I can add my own DOT files using the Doxygen \dotfile
command. The DOT language is quite simple, so I can define the call & collaboration graphs that I want manually. However, this is tedious and leads to a lot of duplicated code.
Semi-manual approach
I was wondering if there is a middle-ground approach. I'm imagining a command that tells Doxygen which functions are called. For instance, in the code below I propose a new Doxygen command \calls
, which would manually tell Doxygen that main()
calls foo()
and bar()
. I know this would be a DRY violation and therefore error prone, but it makes sense for my situation where I am documenting legacy code that is unlikely to change. Could I do this by making some simple edits to the filter?
%> \brief Demo function
function result = foo()
result = 1;
end
%> \brief Demo function
function result = bar()
result = 1;
end
%> \brief Demo function
%> \calls foo, bar
function result = main()
var_1 = foo();
var_2 = bar();
result = var_1 + var_2;
end
External callgraph generator
This callgraph generator supports MATLAB and returns a DOT output, but I'm not sure how I would include it in my pipeline. I would have to automate some process where it generates dotfiles that are automatically pulled into Doxygen.
Upvotes: 0
Views: 32