PDA

View Full Version : Using JSDuck for documenting PHP classes



steffenbrem
29 Oct 2012, 3:22 AM
Hello,

I've tried JSDuck and it's a great documenting tool! But only for Javascript. I have a Ext App, with a big PHP back-end. Because multiple developers will get involved, I need to create documentation for the PHP-backend + the Ext JS app.

Documenting the Ext JS app is no problem, I can generate it in JSDuck with no problems. But when I want to document a simple PHP file:



<?php
/**
* @class MyClass
*/
class MyClass
{
/**
* Test method
* @method
*/
public function method()
{

}
}


When I want to generate docs for this PHP class, it throws the following error:


Error: Error while parsing /Applications/XAMPP/xamppfiles/htdocs/jsduck_php_test/Class.php: Line 1: Unexpected token <


Is there some trick to suppress those errors or to support the PHP syntax? I really hope somebody could help me out here!


Steffen

sdt6585
29 Oct 2012, 4:11 AM
You might want to check out something like this: http://www.phpdoc.org/ for documenting PHP. The regular expressions used in JSDuck to parse javascript will likely continue to cause problems when applied to PHP code given the differences in syntax.

steffenbrem
29 Oct 2012, 5:10 AM
I've heard that sombody from the Sencha Support Team got it working with JAVA, PHP and Ruby. So I guess it is possible to render a JSDuck documentation from a PHP class.

PHPDoc is not really an option, since it doesn't fill the needs of a good documentation.

sdt6585
29 Oct 2012, 5:18 AM
You might send jratcliff a pm and ask him to come comment then. It seems he got it to work from this forum post:

(http://www.sencha.com/forum/showthread.php?192761-Is-It-Possible-To-Use-JSDuck-On-Java-Code&p=778165&viewfull=1#post778165)http://www.sencha.com/forum/showthread.php?192761-Is-It-Possible-To-Use-JSDuck-On-Java-Code&p=778165&viewfull=1#post778165

Good Luck.

steffenbrem
29 Oct 2012, 5:55 AM
I've send him a private message, I hope he can help me with this. If I got the answer, I will post it here.

Thanks for your help!

jratcliff
29 Oct 2012, 5:28 PM
What version of JSDuck are you using? I was using 3.5 when I was creating docs for PHP and Ruby. Starting with 4.0 there was a JavaScript parser added and so I'm not even sure if this is now doable with this version. Try a 3.x version to see if it will work. In the meantime, I'll see what is possible with 4.x.

steffenbrem
30 Oct 2012, 12:02 AM
Hello,

Thanks for your answer! I am using the latest version at the moment (JSDuck 4.3.2). I will give version 3.5 a try, it would be nice if it worked in the newer versions too though :)

Thanks to all!


Steffen

steffenbrem
30 Oct 2012, 12:44 AM
Well! I actually got it working now with version 3.11.2! It renders the documentation nicely without problems :D

I used the following command to install jsduck 3.11.2 (Max OSX):

sudo gem install jsduck -v 3.11.2

Now i just go to my project folder with the PHP source files and use: jsduck -o docs ./src/*.php

Thanks for all the help!