It is a relatively simple thing to generate DoxyGen comments from EA by changing code templates. In this post I will detail how to write a custom template to generate the DoxyGen comments that looks like the built-in JAVADOC_COMMENT macro in EA.
Create DOXYGEN_COMMENT Template
In the Code Template Editor, click the 'Add New Custom Template' button. Select <None> and enter DOXYGEN_COMMENT. This creates a template that can be called as a function from any other template in EA.
To make it work in the same way as JAVADOC_COMMENT it needs to receive a single parameter of the width allowed. It also needs to detect what comment it needs to generate.
$wrapLen = $parameter1
%if opGUID!=""%
$notes = %opNotes% + "\n\n"
$notes += %list="Parameter__Notes" @separator="\n" @indent=""%
%elseIf attGUID!=""%
$notes = %attNotes%
%else%
$notes = %classNotes%
$notes += "\n@author " + %classAuthor%
$notes += "\n@version " + %classVersion%
%endIf%
$notes = %TRIM($notes)%
%if $notes == ""%
%endTemplate%
$notes = %WRAP_LINES($notes, $wrapLen, "/// ")%
/// %MID($notes, 4)%
This gets most of the information generated in the JAVADOC_COMMENT macro. However, in order to get the parameter notes it needs to list over all the parameters. It does this with a new Parameter__Notes template.
Create Parameter__Notes Template
To create this macro click the 'Add New Custom Template' button. Select Parameter and enter Notes. This allows EA to recognize that this template is used it iterate over the parameters of a method. The template itself is very simple.
%PI=" "%
@param
%paramName%
%paramNotes%
Calling DOXYGEN_COMMENT
Now that we have a working DOXYGEN_COMMENT template, we need to call it from the Class Notes, Attribute Notes and Operation Notes templates. I have called it when the commenting style is JavaDoc, but you could do something different. All three templates will look as follows.
%if genOptGenComments != "T"%
%endTemplate%
%PI=""%
$wrapLen = %genOptWrapComment%
$style = %genOptCPPCommentStyle%
%if $style == "XML.NET"%
%XML_COMMENT($wrapLen)%
%elseIf $style == "JavaDoc"%
%DOXYGEN_COMMENT($wrapLen)%
%else%
%CSTYLE_COMMENT($wrapLen)%
%endIf%
There are a couple of things that this doesn't do. Firstly, Doxygen support more metadata in its comments than we are currently generating. For example, we could potentially generate operation pre and post conditions into the notes. In order to do this however we would need to create and addin and call this from our template. In practice this could be applied to any model metadata.
Secondly, you can't modify the reverse engineering, so EA won't know what to do with the comment metadata and it will remain in the notes field.