public function testPathHandling() { // default is only stripping the opening slash $this->assertEquals(ltrim(__FILE__, '/'), $this->fixture->getRelativeFilename(__FILE__)); // after setting the current directory as root folder; should strip all but filename $this->fixture->setPath(dirname(__FILE__)); $this->assertEquals(basename(__FILE__), $this->fixture->getRelativeFilename(__FILE__)); // when providing a file in a lower directory it cannot parse and thus it is invalid $this->setExpectedException('InvalidArgumentException'); $this->fixture->getRelativeFilename(realpath(dirname(__FILE__) . '/../phpunit.xml')); }
/** * Make sure the setter can transform string to array and set correct attribute * * @covers DocBlox_Parser::setVisibility * * @return void */ public function testSetVisibilityCorrectlySetsAttribute() { $this->fixture->setVisibility('public,protected,private'); $this->assertAttributeEquals(array('public', 'protected', 'private'), 'visibility', $this->fixture); }
/** * 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; }
/** * Build a list of files (from the fileset elements) and call the DocBlox parser * @return string */ private function parseFiles() { $parser = new DocBlox_Parser(); DocBlox_Parser_Abstract::$event_dispatcher = new sfEventDispatcher(); $parser->setTitle($this->title); $paths = array(); // filesets foreach ($this->filesets as $fs) { $ds = $fs->getDirectoryScanner($this->project); $dir = $fs->getDir($this->project); $srcFiles = $ds->getIncludedFiles(); foreach ($srcFiles as $file) { $paths[] = $dir . FileSystem::getFileSystem()->getSeparator() . $file; } } $this->log("Will parse " . count($paths) . " file(s)", Project::MSG_VERBOSE); $files = new DocBlox_Parser_Files(); $files->addFiles($paths); $parser->setPath($files->getProjectRoot()); return $parser->parseFiles($files); }
/** * Build a list of files (from the fileset elements) and call the DocBlox parser * @return string */ private function parseFiles() { $parser = new DocBlox_Parser(); $parser->setTitle($this->title); if ($this->quiet) { $parser->setLogLevel(Zend_Log::CRIT); } $files = array(); // filesets foreach ($this->filesets as $fs) { $ds = $fs->getDirectoryScanner($this->project); $dir = $fs->getDir($this->project); $srcFiles = $ds->getIncludedFiles(); foreach ($srcFiles as $file) { $files[] = $dir . FileSystem::getFileSystem()->getSeparator() . $file; } } $this->log("Will parse " . count($files) . " file(s)", Project::MSG_VERBOSE); return $parser->parseFiles($files); }
/** * Execute the parsing process. * * @throws Zend_Console_Getopt_Exception * * @return void */ public function execute() { $files = $this->parseFiles(); if (count($files) < 1) { throw new Zend_Console_Getopt_Exception('No parsable files were found, did you specify any using the -f or -d parameter?'); } $parser = new DocBlox_Parser(); $parser->setTitle(htmlentities($this->getTitle())); if ($this->getVerbose()) { $parser->setLogLevel(DocBlox_Core_Log::DEBUG); } if ($this->getQuiet()) { $parser->setLogLevel(DocBlox_Core_Log::QUIET); } $parser->setExistingXml($this->getTarget() . '/structure.xml'); $parser->setIgnorePatterns($this->getIgnore()); $parser->setForced($this->getForce()); $parser->setMarkers($this->getMarkers()); $parser->setValidate($this->getValidate()); $parser->setPath($parser->getCommonPath($files)); // save the generate file to the path given as the 'target' option file_put_contents($this->getTarget() . '/structure.xml', $parser->parseFiles($files)); }
if (count($opts->getFiles()) < 1) { throw new Zend_Console_Getopt_Exception('No parsable files were found, did you specify any using the -f or -d parameter?'); } } catch (Zend_Console_Getopt_Exception $e) { // if the message actually contains anything, show it. if ($e->getMessage()) { echo $e->getMessage() . PHP_EOL . PHP_EOL; } // show help message and exit the application echo $opts->getUsageMessage(); exit; } // initialize the parser and pass the options as provided by the user or defaults $docblox = new DocBlox_Parser(); $docblox->setLogLevel($opts->getOption('verbose') ? Zend_Log::DEBUG : $docblox->getLogLevel()); $docblox->setExistingXml(is_readable($path.'/structure.xml') ? file_get_contents($path.'/structure.xml') : null); $docblox->setIgnorePatterns($opts->getIgnorePatterns()); $docblox->setForced($opts->getOption('force')); $docblox->setMarkers($opts->getMarkers()); $docblox->setValidate($opts->getOption('validate')); // save the generate file to the path given as the 'target' option file_put_contents($path.'/structure.xml', $docblox->parseFiles($opts->getFiles()));
/** * Execute the parsing process. * * @throws Zend_Console_Getopt_Exception * * @return void */ public function execute() { $files = new DocBlox_Parser_Files(); $files->setAllowedExtensions($this->getExtensions()); $files->setIgnorePatterns($this->getIgnore()); $paths = array_unique($this->getFilename() ? explode(',', $this->getFilename()) : DocBlox_Core_Abstract::config()->getArrayFromPath('files/file')); $files->addFiles($paths); $paths = array_unique($this->getDirectory() || !empty($paths) ? explode(',', $this->getDirectory()) : DocBlox_Core_Abstract::config()->getArrayFromPath('files/directory')); $files->addDirectories($paths); $parser = new DocBlox_Parser(); $parser->setTitle(htmlentities($this->getTitle())); $parser->setExistingXml($this->getTarget() . '/structure.xml'); $parser->setForced($this->getForce()); $parser->setMarkers($this->getMarkers()); $parser->setValidate($this->getValidate()); $parser->setVisibility($this->getVisibility()); $parser->setDefaultPackageName($this->getDefaultpackagename()); $parser->setPath($files->getProjectRoot()); try { // save the generate file to the path given as the 'target' option file_put_contents($this->getTarget() . '/structure.xml', $parser->parseFiles($files)); } catch (Exception $e) { if ($e->getCode() === DocBlox_Parser_Exception::NO_FILES_FOUND) { throw new Zend_Console_Getopt_Exception('No parsable files were found, did you specify any using the -f or -d parameter?'); } throw new Zend_Console_Getopt_Exception($e->getMessage()); } }