dokapi/dokapi

This package is abandoned and no longer maintained. No replacement package was suggested.

Documentation generator

Installs: 6 193

Dependents: 1

Suggesters: 0

Security: 0

Stars: 6

Watchers: 5

Forks: 1

Open Issues: 0

Type:standalone

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

This package is not auto-updated.

Last update: 2017-11-28 07:08:16 UTC


README

Generate documentation from your code.

Usage

<?php

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->loadDefaultProcessors();
$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.property
  • token.php.function
  • token.php.annotation