public function testShouldThrowExceptionForInvalidViewObject() { $exception = null; try { $renderer = new Renderer([], 'foo'); $renderer->render(); } catch (\Exception $e) { $exception = $e; } $this->assertInstanceOf('\\Vegas\\ApiDoc\\Exception\\InvalidViewComponentException', $exception); }
/** * 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()); }