Book a Demo

Author Topic: Custommized code generation templates  (Read 3639 times)

Juergen

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Custommized code generation templates
« on: November 11, 2008, 01:47:02 am »
Hi everybody.

I would like to change the code generation template for the C++ comments.
What I would like to do, is to change the template so that the generated comment is useing the doxygen style
which is similar to the javadoc style.
I have finished almost everythig, except the parameter list of the operations.

The comment below is the goal which I would like to reach.

/*! \brief This is a brief description of a member function
 *
 * The detailed description followes here
 *
 * \param myChar    [char ]  The character which will be printed
 * \param cNrOfChar [const int]  Number of printed charaters
 *
 * \return  This is the result. 0: Okay; -1 Failed [int]
 */

int printCharacter( char myChar, const int cNrOfChar );

My problem is to generate the comment part of the function parameters.

The only possebility which I have found in the EA was to use the following
template command:
$myList += %list="Parameter" @separator="\n" @indent=" *  \param"%

But with this command I will receive the wrong order of the parameter elements:
[paramType] [paramName] but I need [paramName] [paramType]

I have also tried to use the list command with the Fiel Substition Macros "paramName" instead of "Parameter" but unfotunately without any success.

Please can somone give mea hint how I can solve this problem?

Thanks a lot.

Best regards

Juergen

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Custommized code generation templates
« Reply #1 on: November 11, 2008, 07:55:14 am »
Have a look at custom templates.  (http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/customtemplates.html)  The example on that page is almost exactly what you want.

Juergen

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Custommized code generation templates
« Reply #2 on: November 11, 2008, 07:47:32 pm »
Quote
Have a look at custom templates.  (http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/customtemplates.html)  The example on that page is almost exactly what you want.

Thanks for the hint.
I have checked it out before.
But I was not quite sure if this example will solve my requirements.
Now I have tried to use this example.
I added to the Template "Operation Notes" the following line:

%Parameter__JavaDoc%

then I always get the following error:

Error in code templates. Stack limit reached in template Parameter_JavaDoc

After that I have to kill EA.

Here is what I have entered:

/**
$notes = %opNotes%
%if $notes != ""%
$notes += "\n"
%endIf%
$notes += %list="Parameter_JavaDoc" @separator="\n"%
%WRAP_COMMENT($notes, genOptWrapComment, " ",  "* ")%
*/


My problem with this example is that I don't understand what
%list="Parameter_JavaDoc" @separator="\n"%
does exactly?

My goal is to reach the following output:
"\param [paramName] [paramType] [paramNotes]"

Thanks again for the help.
Best regards

Juergen

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Custommized code generation templates
« Reply #3 on: November 12, 2008, 08:11:41 am »
You're calling the Parameter__Javadoc template from the Parameter__Javadoc template with no terminating condition.  What did you expect to happen?  At least EA provided one and a description of what went wrong.

In your operation Notes template you need to have the list over operation parameters.

Code: [Select]
/**
$notes = %opNotes%
%if $notes != ""%
$notes += "\n"
%endIf%
$notes += %list="Parameter_Javadoc" @separator="\n"%
%WRAP_COMMENT($notes, genOptWrapComment, " ",  "* ")%
*/

In the custom template, you need to have the code to generate what you want for each parameter.

Code: [Select]
%PI=" "%
\param
%paramName%
[%paramFixed == "T" ? "const "%%paramType%]
%paramNotes%

Note that I haven't run the above template.
« Last Edit: November 12, 2008, 08:13:15 am by simonm »

Juergen

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Custommized code generation templates
« Reply #4 on: November 12, 2008, 05:25:15 pm »
Quote
You're calling the Parameter__Javadoc template from the Parameter__Javadoc template with no terminating condition.  What did you expect to happen?  At least EA provided one and a description of what went wrong.

In your operation Notes template you need to have the list over operation parameters.

Code: [Select]
/**
$notes = %opNotes%
%if $notes != ""%
$notes += "\n"
%endIf%
$notes += %list="Parameter_Javadoc" @separator="\n"%
%WRAP_COMMENT($notes, genOptWrapComment, " ",  "* ")%
*/

In the custom template, you need to have the code to generate what you want for each parameter.

Code: [Select]
%PI=" "%
\param
%paramName%
[%paramFixed == "T" ? "const "%%paramType%]
%paramNotes%

Note that I haven't run the above template.
Of course!

Sorry for my questioning.
But I was really confused by the example which is in your online help.
But now I got it and it works fine.
Thanks a lot for the help.

Best regards

Juergen