Exemple #1
0
 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'));
 }
Exemple #2
0
 /**
  * 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));
 }
 /**
  * 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);
 }
Exemple #4
0
 /**
  * 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());
     }
 }