views:

212

answers:

2

I would like to build some smaller scale but hightly customized documentation sites for a few projects. PhpDocumentor is pretty great but it is very heavy. I thought about trying to tweak the templates for that but after spending only a couple of minutes looking into it I decided that it would be too much work.

Ideally I'd like to see something to which I could pass a bunch of files and have it return all of the files, classes and properties and methods, along with their meta data, so that I could build out some simple templates based on the data.

Are there any DocBlock parser-only projects that will help me in this task, or am I stuck reinventing that wheel?

+4  A: 

You can do this easily yourself with the Reflection API.

See this tutorial: http://www.phpriot.com/articles/reflection-api

Gordon
Using Reflection is a great suggestion, and it is pretty straightforward. Unless there are other canned solutions provided that do a lot of this work for me, I'll go down this path.
Beau Simensen
To use reflection, don't you somehow have to load the PHP script containing the class of interest? How do you accomplish that, for an arbitarily long list of PHP scripts?
Ira Baxter
@Ira See the example at http://de3.php.net/manual/en/reflectionclass.getdoccomment.php - if you want to parse files for classes, you can use http://github.com/theseer/Autoload/blob/master/src/classfinder.php and to iterate over directories you use http://de3.php.net/manual/en/class.recursivedirectoryiterator.php
Gordon
A: 

You appear to want a PHP parser that can export particular details of what has been parser.

See the Semantic Designs PHP Front End for a full PHP 4/5 parser. It parsers PHP source code, builds abstract syntax trees, stamping each node with precise location information, and makes them available for further use. One general thing it can do is to print out any subtree back as the original text.

In your case, you'd want to scan over the trees, find the classes/methods/properties (as tree nodes) and print their source text, along with the location information. I think that would deliver exactly what you want.

Ira Baxter