コード例 #1
0
 /**
  * Generates documentation
  *
  * Usage
  * <code>
  * php cli/cli.php app:apidoc generate
  * </code>
  */
 public function generateAction()
 {
     /**
      * @var \Phalcon\Events\Manager $eventsManager
      */
     $eventsManager = $this->di->get('eventsManager');
     /**
      * Benchmarks building annotations collections
      */
     $buildBenchmark = new Benchmark();
     $eventsManager->attach('generator:beforeBuild', function () use($buildBenchmark) {
         $buildBenchmark->start();
     });
     $eventsManager->attach('generator:afterBuild', function () use($buildBenchmark) {
         $buildBenchmark->finish();
     });
     /**
      * Benchmarks rendering html
      */
     $renderBenchmark = new Benchmark();
     $eventsManager->attach('generator:beforeRender', function () use($renderBenchmark) {
         $renderBenchmark->start();
     });
     $eventsManager->attach('generator:beforeRender', function () use($renderBenchmark) {
         $renderBenchmark->finish();
     });
     //instantiates generator by passing the input directory and regular expression for matching file names
     //set verbose on true to get information about parsed classes
     $generator = new Generator($this->getInputPath(), ['match' => '/(.*)Controller(.*)\\.php/i', 'verbose' => true]);
     $generator->setEventsManager($eventsManager);
     //builds information
     $collections = $generator->build();
     //get the view object that will be rendering output html
     $view = $this->getView();
     //instantiate default renderer
     $renderer = new Renderer($collections, $this->getLayoutFilePath());
     $renderer->setView($view);
     /**
      * Injects benchmarks into view
      */
     $renderer->setViewVar('buildBenchmark', $buildBenchmark);
     $renderer->setViewVar('renderBenchmark', $renderBenchmark);
     //sets renderer to generator
     $generator->setRenderer($renderer);
     //creates output file
     file_put_contents($this->getOutputPath() . 'index.html', $generator->render());
 }
コード例 #2
0
ファイル: GeneratorTest.php プロジェクト: vegas-cmf/apidoc
 public function testShouldSwitchAnnotationsReader()
 {
     $generator = new \Vegas\ApiDoc\Generator(APP_ROOT . '/app/modules', ['match' => '/(.*)Controller(.*)\\.php/i', 'verbose' => false]);
     $generator->setupAnnotationsReader(new \Phalcon\Annotations\Adapter\Files());
     $this->assertInstanceOf('\\Phalcon\\Annotations\\Adapter\\Files', $generator->getAnnotationsReader());
 }