Archive for January 30th, 2007

Custom PhpDocumentor Templates

January 30th, 2007

PhpDocumentor is an essential tool all serious PHP developers should know about.
By parsing the phpdoc blocks within the source of your files phpDocumentor can generate API documentation for your entire project/application.

I recently had the need to build a custom output template for the HTML converter, and decided to distribute it using a PEAR installable package so other PHP developers at the University could generate documentation for their code.

The process is fairly straightforward – I copied the frames template and created my own named ‘UNL.’ This template yields .php pages in the UNL Templates so that the API documentation matches the rest of the www.unl.edu website.

Tricks with creating an installable PEAR package were to mark all the files .tpl, .inc, etc as ‘php’ and to use ‘/’ as the baseinstalldir. This will make sure the template files get installed into the correct location.

Other UNL PHP developers can run:

pear install pear.unl.edu/UNL_PhpDocumentor_UNLHTMLTemplate-alpha

And then set phpDocumentor loose on your files like so:

phpdoc -po UNL_DWT -o HTML:UNL:UNL -d UNL_DWT -t /Library/WebServer/pear.unl.edu/docs/UNL_DWT/

which will generate API documentation within the UNL templates and it will look like this.