/** * Tests whether setting a target succeed. * * @return void */ public function testTarget() { $this->assertEquals('', $this->fixture->getTarget()); $this->fixture->setTarget(dirname(__FILE__)); $this->assertEquals(dirname(__FILE__), $this->fixture->getTarget()); // only directories are accepted, not files $this->setExpectedException('Exception'); $this->fixture->setTarget(__FILE__); // only valid directories are accepted $this->setExpectedException('Exception'); $this->fixture->setTarget(dirname(__FILE__) . 'a'); }
public function testExecuteTransform() { touch('/tmp/docblox_a'); @unlink('/tmp/docblox_b'); $this->assertFileExists('/tmp/docblox_a'); $this->assertFileNotExists('/tmp/docblox_b'); $tr = new DocBlox_Transformer(); $tr->setTarget('/tmp'); try { $t = new DocBlox_Transformer_Transformation($tr, 'copyz', 'FileIo', '/tmp/docblox_a', 'docblox_b'); $this->fixture->transform(new DOMDocument(), $t); $this->fail('When un unknown query type is used an exception is expected'); } catch (InvalidArgumentException $e) { // this is good } $t = new DocBlox_Transformer_Transformation($tr, 'copy', 'FileIo', '/tmp/docblox_a', 'docblox_b'); $this->fixture->transform(new DOMDocument(), $t); $this->assertFileExists('/tmp/docblox_a'); $this->assertFileExists('/tmp/docblox_b'); unlink('/tmp/docblox_a'); unlink('/tmp/docblox_b'); }
/** * Execute the task * * @return Docblox * @throw BuildException */ public function execute() { if (!class_exists('Parser')) { if (!$this->getLibraryPath()) { throw new BuildException('No Docblox library path set'); } $libraryPath = $this->filterProperties($this->getLibraryPath()); set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath); require_once 'markdown.php'; $autoloader = new StandardAutoloader(); $autoloader->registerPrefix('Zend', "{$libraryPath}/Zend")->registerPrefix('DocBlox', "{$libraryPath}/DocBlox")->setFallbackAutoloader(true)->register(); } $parser = new Parser(); ParserAbstract::$event_dispatcher = new sfEventDispatcher(); if ($this->getForce()) { $parser->setForced($this->getForce()); } if ($this->getMarkers()) { $parser->setMarkers($this->getMarkers()); } if ($this->getTitle()) { $parser->setTitle($this->filterProperties($this->getTitle())); } if ($this->getValidate()) { $parser->setValidate($this->getValidate()); } $files = new Files(); foreach ($this->getFiles() as $file) { $files->addFile($this->filterProperties($file)); } $xml = $parser->parseFiles($files); $transformer = new Transformer(); $transformer->setSource($xml); if ($this->getParsePrivate()) { $transformer->setParseprivate($this->getParsePrivate()); } if ($this->getTarget()) { $transformer->setTarget($this->filterProperties($this->getTarget())); } if ($this->getThemesPath()) { $transformer->setThemesPath($this->filterProperties($this->getThemesPath())); } else { $transformer->setThemesPath(CoreAbstract::config()->paths->themes); } if ($this->getTemplates()) { $transformer->setTemplates($this->getTemplates()); } else { $transformer->setTemplates(CoreAbstract::config()->transformations->template->name); } $transformer->execute(); return $this; }
/** * Task entry point * @see Task::main() */ public function main() { if (empty($this->destDir)) { throw new BuildException("You must supply the 'destdir' attribute", $this->getLocation()); } if (empty($this->filesets)) { throw new BuildException("You have not specified any files to include (<fileset>)", $this->getLocation()); } $this->initializeDocBlox(); $xml = $this->parseFiles(); $this->log("Transforming...", Project::MSG_VERBOSE); $transformer = new DocBlox_Transformer(); $transformer->setTemplatesPath(DocBlox_Core_Abstract::config()->paths->templates); $transformer->setTemplates(DocBlox_Core_Abstract::config()->transformations->template->name); $transformer->setSource($xml); $transformer->setTarget($this->destDir->getAbsolutePath()); $transformer->execute(); }
/** * Task entry point * @see Task::main() */ public function main() { if (empty($this->destDir)) { throw new BuildException("You must supply the 'destdir' attribute", $this->getLocation()); } if (empty($this->filesets)) { throw new BuildException("You have not specified any files to include (<fileset>)", $this->getLocation()); } $this->initializeDocBlox(); $xml = $this->parseFiles(); $transformer = new DocBlox_Transformer(); $transformer->setSource($xml); $transformer->setTarget($this->destDir); $transformer->execute(); }
/** * Executes the transformation process. * * @throws Zend_Console_Getopt_Exception * * @return void */ public function execute() { // initialize timer $timer = microtime(true); // initialize transformer $transformer = new DocBlox_Transformer(); $transformer->setTarget($this->getTarget()); $transformer->setSource($this->getSource()); $transformer->setTemplates($this->getTemplate()); // enable verbose mode if the flag was set if ($this->getVerbose()) { $transformer->setLogLevel(DocBlox_Core_Log::DEBUG); } if ($this->getQuiet()) { $transformer->setLogLevel(DocBlox_Core_Log::QUIET); } // start the transformation process if (!$this->getQuiet()) { echo 'Starting transformation of files (this could take a while depending upon the size of your project)' . PHP_EOL; } $transformer->execute(); if (!$this->getQuiet()) { echo 'Finished transformation in ' . round(microtime(true) - $timer, 2) . ' seconds' . PHP_EOL; } }
/** * Executes the transformation process. * * @throws Zend_Console_Getopt_Exception * * @return void */ public function execute() { // initialize timer $timer = microtime(true); // initialize transformer $transformer = new DocBlox_Transformer(); $transformer->setThemesPath(DocBlox_Core_Abstract::config()->paths->themes); $transformer->setTarget($this->getTarget()); $transformer->setSource($this->getSource()); $transformer->setTemplates($this->getTemplate()); $transformer->setParseprivate($this->getParseprivate()); // add links to external docs $external_class_documentation = DocBlox_Core_Abstract::config()->getArrayFromPath('transformer/external-class-documentation'); $external_class_documentation = !is_numeric(current(array_keys($external_class_documentation))) ? $external_class_documentation = array($external_class_documentation) : $external_class_documentation; /** @var DocBlox_Core_Config $doc */ foreach ($external_class_documentation as $doc) { if (empty($doc)) { continue; } $transformer->setExternalClassDoc((string) $doc['prefix'], (string) $doc['uri']); } // start the transformation process if (!$this->getQuiet()) { echo 'Starting transformation of files (this could take a while depending upon the size of your project)' . PHP_EOL; } $transformer->execute(); if (!$this->getQuiet()) { echo 'Finished transformation in ' . round(microtime(true) - $timer, 2) . ' seconds' . PHP_EOL; } }