Parsing Javascript files with phpDocumentor

I recently played with phpDocumentor and found it quite suitable for my needs. I mainly work with PHP / HTML / JS / CSS code bases and would like phpDocumentor to parse my Javascript (and possibly CSS) to keep it all together.

I managed to get phpdoc to parse the javascript files contained in the codebase, but it rejects the dock block at page level, which causes it to reject various tags (see below). I found that by adding PHP to the open tag (with the JavaScript comment in front of it) at the beginning of the JavaScript file, I can get it to parse it just like a PHP file.

// <?php /** * phpdoc goes here * @package * @todo * - Todo 1 * - Todo 2 */ function javascript(goes, here) { } 

I can think about the problem that arises if the web server is configured on the server .js files through PHP. Are there any other issues you might think about? Is there a better way to do this?

thanks

+4
source share
3 answers

As for potential problems, the idea comes to your mind that since you are โ€œtrickingโ€ phpDocumentor to parse docblock and JS code, you implicitly rely on the PHP tokenizer (how phpDocumentor parses the PHP code internally) to successfully read your JS- code and treat it like php code. When that succeeds, I think you will have good results ... your simple function example is likely to be successful. However, if your JS code is not successfully parsed as PHP code, then I am sure that phpDocumentor will not perceive it as a document element of the code, and therefore it will not be displayed in your documents.

+4
source

I think this is a bit naive assumption to think that there is no such tool for JavaScript.

There is a tool called JSDoc , which is basically the same as phpdoc, but for JavaScript.


Update Friday, May 1, 2015: -

It seems that the new project link: -

https://github.com/jsdoc3/jsdoc

+7
source

I am looking for the same thing. I found JSDoc and PhpDocumentor, but given the fact that application 1 (ONE) as "Integer" contains both PHP and JavaScript, creating the application base, I would prefer 1 approach to documenting projects. It really sucks to have 2 documentation sets, 1 for php and 1 for JavaScript. That ole @see or inline @link does not work in case @see is this other function / class in this other langauge, through some other documentation program .... get my drift?

0
source

All Articles