Book a Demo

Author Topic: Operation note comments in plain c++  (Read 3545 times)

gds

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Operation note comments in plain c++
« on: March 25, 2014, 11:05:32 am »
Is it possible to generate this type of comment for a c++ function declaration without using the javadoc style comments?

Code: [Select]
//--------------------
// This describes
// theFunction() in two lines
// @return  It returns an int  <-- end of operation note.
//
// @param A  parameter A does this  <--parameter note
// @param B  parameter B does this  <--parameter note
//
int theFunction(int A, int B);

I realize that javadoc does a similar thing but with the standard c style comments which is OK. I can also produce the above style, using the WRAP_COMMENT macro you pointed out before, if I type the parameter notes directly into the operation notes. But is there a way to have the parameter notes automatically appear in this style of comment like they do for javadoc?

Thanks.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Operation note comments in plain c++
« Reply #1 on: March 26, 2014, 08:51:15 am »
Yes, but there is a little more to it.

First, create a custom template for parameters called Notes.
Code: [Select]
%PI=" "%
@param
%paramName%
%paramNotes%

In your operation notes template you can now list over these.
Code: [Select]
$params = %list="Parameter__Notes" @separator="\n"%/code]

Then combine them [code]%if opNotes == "" and $params == ""%
%endTemplate%

%if opNotes == ""%
$comment=$params
%elseIf $params == ""%
$comment=%opNotes%
%else%
$comment=%opNotes%+"\n\n"+$params
%endIf%

After that you can pass $comment into WRAP_COMMENT.

gds

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Operation note comments in plain c++
« Reply #2 on: April 01, 2014, 03:41:03 am »
Thank again! That worked. I did basically what you describe. Here's what I did with some gaps filled in for other newbs:

In code template editor for c++, do "add new custom template":
Template Type: Parameter
Template Name: Notes
Produces new template called Parameter__Notes

Put this inside Parameter__Notes:
Code: [Select]
%PI=" "%
@param
%paramName%
  
%paramNotes%
Note: The blank line contains 3 leading spaces for additional separation.

Then edit the existing Operation Notes template to contain this:
Code: [Select]
%if genOptGenComments != "T" or genOptCPPGenMethodNotesInHeader != "T"%
%endTemplate%

$params = %list="Parameter__Notes" @separator="\n"%

%if opNotes == "" and $params == ""%
%endTemplate%

%if opNotes == ""%
$comment=$params
%elseIf $params == ""%
$comment=%opNotes%
%else%
$comment=%opNotes%+"\n\n"+$params
%endIf%
$comment += "\n "

%PI=""%
$wrapLen = %genOptWrapComment%
$style = %genOptCPPCommentStyle%

%if $style == "XML.NET"%
%XML_COMMENT($wrapLen)%
%elseIf $style == "JavaDoc"%
%WRAP_COMMENT($comment, $wrapLen, "", "// ")%
%else%
%CSTYLE_COMMENT($wrapLen)%
%endIf%

Does exactly what I want!

-gds