How to make phpdocumentor recognise non-php file extensions

Category: Note to Self, PHP

(Update 17 Dec 2012: This post relates to PhpDocumentor version 1. Version 2 is now out and allows configuration on a per-project basis, see comments below)

I use  phpdocumentor to generate documentation for my custom PHP projects, but by default it will only process files with the standard file extensions (.php, .phtml .inc etc). However Drupal makes use of  non-standard extensions .install and .module. Phpdocumentor needs to be told this.

To do that, edit  phpDocumentor.ini. On my Fedora system it is located:

 /usr/share/pear/data/PhpDocumentor.ini

Find  the group [_phpDocumentor_phpfile_exts] and add required suffixes so it looks something like this:

[_phpDocumentor_phpfile_exts]
php
php3
php4
phtml
inc
module
install

2 Comments

  1. Martin
    December 17, 2012

    After looking for phpDocumentor.ini for quite a while I found that it seems as ~/pear/share/pear/phpDocumentor/data/phpdoc.tpl.xml replaced phpDocumentor.ini in PHPDocumentor 2.

    I know it’s a pretty odd place the file is placed but the point is that it worked and I am now generating docs for my whole Drupal project .module, .inc and .install included.

    • Lopez
      December 17, 2012

      Hi Martin, thanks for your comment.

      I didn’t know PhpDocumentor 2 was out, I’ll update my post to clarify that it relates to version 1.

      Just had a very quick play with v2 and there look to be some nice improvements. For configuration you don’t have to touch the default config anymore, but can supplement it by adding a file called phpdoc.dist.xml to your working directory. This will be picked up automatically by phpdoc.

      Example phpdoc.dist.xml:

      <?xml version="1.0" encoding="UTF-8" ?>
      <phpdoc>
          <title>My Drupal Project</title>
          <parser>
              <extensions>
                  <extension>module</extension>
                  <extension>inc</extension>
                  <extension>install</extension>
                  <extension>php</extension>
                  <extension>php3</extension>
                  <extension>phtml</extension>
              </extensions>
          </parser>
      </phpdoc>

      Cheers!

Leave a Reply

You must be logged in to post a comment.