Book a Demo

Author Topic: Comments for PHP like phpDocumentor  (Read 2954 times)

SeboStone

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Comments for PHP like phpDocumentor
« 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:
Code: [Select]
     /**
       * the constructor
       *
       * @param server    the database server
       */

phpDocumentor need:
Code: [Select]
     /**
       * the constructor
       *
       * @param string $server the database server
       */

now I have this:
Code: [Select]
     /**
       * the constructor
       *
       * @param $server
       */

that's my Generator Code:
Code: [Select]
/**
$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

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Comments for PHP like phpDocumentor
« Reply #1 on: April 04, 2008, 10:52:24 am »
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
Code: [Select]
$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
Code: [Select]
%PI=" "%
"@param"
%paramType%
%dl%%paramName%
%paramNotes%

T. Rakowski

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Comments for PHP like phpDocumentor
« Reply #2 on: April 11, 2008, 07:46:15 am »
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:
Code: [Select]
     /**
       * "@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:
Code: [Select]
/**
     * Enter description here...
     *
     * @param String $someString
     * @param Test $customObject
     */
    public function login($someString, Test $customObject) {
    }

now the code below will raise warnings during execution.
Code: [Select]
public function login(String $someString, Test $customObject) {

I've modified Parameter template to look like this:
Code: [Select]
%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
« Last Edit: April 11, 2008, 07:48:52 am by phraktal »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Comments for PHP like phpDocumentor
« Reply #3 on: April 11, 2008, 09:10:05 am »
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
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Comments for PHP like phpDocumentor
« Reply #4 on: April 11, 2008, 09:32:49 am »
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.