Author Topic: Support Doxygen Comments  (Read 6820 times)

Adria

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Support Doxygen Comments
« on: December 16, 2008, 09:24:06 am »
It would be great if EA supported the Doxygen commenting style.
My requirement is for this in the C world, but I'm sure others would appreciate it for other languages.

AndyDent

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Support Doxygen Comments
« Reply #1 on: December 23, 2008, 01:55:36 am »
count me in as a longtime Doxygen fan!

Wowbagger

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Re: Support Doxygen Comments
« Reply #2 on: February 14, 2009, 08:21:43 am »
Add me in as well.

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Support Doxygen Comments
« Reply #3 on: February 15, 2009, 08:33:27 am »
Hi all of you doxygen fans,

Doesn't doxygen understand javadoc? Mine does.
What's exactly the problem with the javadoc style comments generated by EA? If there are any, you could try to adjust the code generation templates ...

WBR
Günther
« Last Edit: February 15, 2009, 08:34:58 am by g.makulik »
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

Hendrik

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Support Doxygen Comments
« Reply #4 on: February 20, 2009, 10:42:23 pm »
I have a similar request. We too use doxygen for source code documentation.

While Javadoc is fine for doxygen, we have our own coding and documentation guidelines and it would be nice if EA-generated docs followed a style consistent with our existing code.

For example, we do not use /** ... */, but /// and we use '\' instead of '@' as command prefix.

So, is it possible to tweak the Javadoc-output of EA via templates? In the code template, all I see is a JAVADOC function (or similar).

Also, how would such a change affect reverse-engineering? Can EA import notes that use /// instead of /** ... */?

cheers
Hendrik

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Support Doxygen Comments
« Reply #5 on: February 23, 2009, 07:58:57 am »
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.

Code: [Select]
$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.

Code: [Select]
%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.

Code: [Select]
%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.

Hendrik

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Support Doxygen Comments
« Reply #6 on: February 23, 2009, 06:59:13 pm »
Thanks Simon,

this is excellent. That will probably do for the time being.

It would be great to also have pre- and postconditions and other parameters that doxygen supports. Are you planning to implement something along those lines in the future?

cheers
Hendrik

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8063
  • Karma: +118/-20
    • View Profile
Re: Support Doxygen Comments
« Reply #7 on: February 24, 2009, 07:57:24 am »
The next beta of 7.5 includes access to class constraints, scenarios etc. in the the code templates.  Operation pre & post conditions haven't been included for that build, but I suspect they will be added in the near future.  But for now the call to an add-in will do the job nicely.