Beispiel #1
0
 /**
  * @expectedException \Exception
  */
 public function testCantSaveTheContent()
 {
     $builderOptions = new OptionsBuilder();
     $builderOptions->setApiName('testApp');
     $builderOptions->setOutputDir('build/test');
     $builderOptions->setOutputFile('test.html');
     if (!file_exists($builderOptions->getOutputDir())) {
         mkdir($builderOptions->getOutputDir(), 0600, TRUE);
     }
     $this->builder = new Builder(array('Zckrs\\GenDocApi\\Test\\Client'), $builderOptions);
     $this->builder->generate();
 }
 /**
  * Generates the documentation based on sample classes
  */
 protected function generateDoc()
 {
     $builderOptions = new OptionsBuilder();
     $builderOptions->setApiName($this->appName);
     $builderOptions->setApiDescription($this->appDescription);
     $builderOptions->setOutputFile($this->outputFile);
     $builderOptions->setOutputDir(__DIR__ . $this->outputFolder);
     $builderOptions->setTemplateDir(__DIR__ . '/Resources/views');
     $builderOptions->setAssetDir(__DIR__ . '/Resources/assets');
     try {
         $builder = new Builder(array('Zckrs\\GenDocApi\\Test\\Client', 'Zckrs\\GenDocApi\\Test\\Document'), $builderOptions);
         $builder->generate();
     } catch (\Exception $e) {
         $this->fail(sprintf('There was an error generating the documentation: %s', $e->getMessage()));
     }
 }
Beispiel #3
0
<?php

// Use autoload
// require __DIR__.'/../../autoload.php';
// Or include classes
require_once __DIR__ . '/src/Builder.php';
require_once __DIR__ . '/src/Extractor.php';
require_once __DIR__ . '/src/Entity/OptionsBuilder.php';
require_once __DIR__ . '/tests/sample/Client.php';
require_once __DIR__ . '/tests/sample/Document.php';
use Zckrs\GenDocApi\Builder;
use Zckrs\GenDocApi\Entity\OptionsBuilder;
// Define classes to search annotations
$classes = array('Zckrs\\GenDocApi\\Test\\Client', 'Zckrs\\GenDocApi\\Test\\Document');
// Options for the Builder. Please see Zckrs\GenDocApi\Entity\OptionsBuilder for available attributes.
$optionsBuilder = new OptionsBuilder();
$optionsBuilder->setApiName('My API');
$optionsBuilder->setApiDescription('That is my awesome API. And this is why you will fall in love with.');
$optionsBuilder->setOutputFile('index.html');
$optionsBuilder->setOutputDir(__DIR__ . '/web');
try {
    $builder = new Builder($classes, $optionsBuilder);
    $builder->generate();
} catch (\Exception $e) {
    echo 'There was an error generating the documentation: ', $e->getMessage();
}