Documentation generator

Installs: 5 688

Dependents: 1

Stars: 6

Watchers: 4

Language: PHP

v0.1.0 2014-02-06 13:46 UTC


Generate documentation from your code.



use Doctrine\Common\Annotations\AnnotationRegistry;

$loader = require __DIR__."/vendor/autoload.php";

AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

$finder = new Symfony\Component\Finder\Finder();
$finder->in('your directory ...');

$dokapi = new Dokapi\Dokapi();
$result = $dokapi->scan($finder);

This library provides a simple yet extensible processor dedicated to static code analysis. A php processor is included.

If you want to generate some documentation for your REST API you should take a look at dokapi-rest.

Add your processor

namespace acme;

use Dokapi\Processor\ProcessorInterface;
use Dokapi\Processor\Collection;
use Dokapi\Result\Result;
use Dokapi\Event\Events;

class ReadMyOwnAnnotationProcessor implements ProcessorInterface
    public function supports($event, $context)
        return Events::TOKEN_PHP_ANNOTATION === $event && $context->getAnnotation() instanceof Acme\Annotation\MyAnnotation();

    public function process($context, Result $result, Collection $collection)
        $annotation = $context->getAnnotation();
        // $model = create a model from the annotation

        // $result is the result wrapper, it's object return on $dokapi->scan() method.
        // $collection is the collection of processor, you can easily dispatch a new|custom event

        $result->set('key', 'ident', $model);

        //$result->getCurrent('key') return last "key" setted.
        //$result->get('key', 'ident') return "key" with ident "ident"

    public function getIdent()
        return 'acme.processor.read_my_own_annotation';

Now, you have to add this processor to dokapi.

$collection = new \Dokapi\Processor\Collection();
$collection->addProcessor(new \acme\ReadMyOwnAnnotationProcessor());

$dokapi = new Dokapi\Dokapi($collection);
$result = $dokapi->scan($finder);

Global events:

  • scan.start
  • scan.end
  • scan.file.start
  • scan.file.end
  • file

PHP events:

  • token.php.class
  • token.php.function
  • token.php.annotation