Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: SeboStone on April 04, 2008, 09:51:20 am
-
Hi!
Excuse my bad English, that's not my native language ....
I write a Code Generation Template, to replace the JAVADOC_COMMENT macro because the output of JAVADOC_COMMENT is not phpDocumentor conformal.
JAVADOC_COMMENT:
/**
* the constructor
*
* @param server the database server
*/
phpDocumentor need:
/**
* the constructor
*
* @param string $server the database server
*/
now I have this:
/**
* the constructor
*
* @param $server
*/
that's my Generator Code:
/**
$notes = %opNotes%
%if $notes != ""%
$notes += "\n\n"
%endIf%
$notes += %list="Parameter" @separator="\n" @indent="@param "%
%WRAP_COMMENT($notes, genOptWrapComment, " ", "* ")%
*/
You see, I have any problems:
How I can print the Parameters Notes and his Type? Have You any idea for me?
Thank you for your help!
Sebo
-
For public record, these templates should get you what you want, but it will not be used when reverse engineering, so avoid reverse engineering unless you want the the types to get reset to var.
Operation Notes $notes = %opNotes%
$paramNotes = %list="Parameter__Notes" @separator="\n" @indent=""%
%if $notes != "" and $paramNotes != ""%
$notes += "\n\n"
%endIf%
$notes += $paramNotes
%if $notes != ""%
/**
%WRAP_COMMENT($notes, genOptWrapComment, " ", "* ")%
*/
%endIf%
Custom Template - Parameter__Notes %PI=" "%
"@param"
%paramType%
%dl%%paramName%
%paramNotes%
-
Hi,
I'm trying to resolve the same problem as SeboStone, and I've attempted to use your solution. I've copy-pasted the code into Paramter__Notes and Operation Notes. In my case, a method generated looks like this:
/**
* "@param" Test $$test
*/
public function setTest(Test $$test)
{
}
The problem is the extra " around @param as well as the double $ around variables. The type is set properly.
Also, I've made another fix in my installation, which probably should be included in your future release. In PHP primitive types should not be specified when declaring parameters of a function. So "String", "Integer", "Boolean" should never be there. They should however appear in phpDocumentor comments. Like in this example:
/**
* Enter description here...
*
* @param String $someString
* @param Test $customObject
*/
public function login($someString, Test $customObject) {
}
now the code below will raise warnings during execution.
public function login(String $someString, Test $customObject) {
I've modified Parameter template to look like this:
%if genOptPHPVersion == "5.0" and paramType != "" and paramType != "var" and paramType != "String" and paramType != "Integer" and paramType != "Boolean"%
%PI=" "%
%paramType%
%endIf%
%PI=""%
%paramKind=="out" ? "&" : ""%
%paramKind=="inout" ? "&" : ""%
%dl%%paramName%
%paramDefault ? " = " value%
That seems to fix the problem on first sight, but it's not completely tested.
Other than that, I do not see any problems. Your program is great, and we should be getting few licenses soon.
Tomasz Rakowski
-
Tomasz,
Please take a moment to fire off a message to Sparx support with a pointer to your post. This is excellent work.
The direct connection - whether trough a bug report, feature request, or support request - is the best way to get something directly into the 'hopper' at Sparx. This is a user forum, though the Sparxians participate actively, as you've seen in this thread.
David
-
Thanks for the correction to my previous template.
Just for the record, we are not planning to integrate this into the default templates at the moment. I promise that if it was, it would be better tested than my quick post, there isn't really any reason to send a message directly to sparx support.