コード例 #1
0
 /**
  * Main entry point into the application.
  *
  * @return void
  */
 public function main()
 {
     $runner = new DocBlox_Task_Runner($_SERVER['argc'] == 1 ? false : $_SERVER['argv'][1], 'project:run');
     $task = $runner->getTask();
     $threshold = DocBlox_Core_Log::WARN;
     if (!$task->getQuiet()) {
         DocBlox_Core_Application::renderVersion();
     } else {
         $threshold = DocBlox_Core_Log::QUIET;
     }
     if ($task->getVerbose()) {
         $threshold = DocBlox_Core_Log::DEBUG;
     }
     $dispatcher = new sfEventDispatcher();
     $logger = new DocBlox_Core_Log(DocBlox_Core_Log::FILE_STDOUT);
     $logger->setThreshold($threshold);
     $dispatcher->connect('system.log', array($logger, 'log'));
     DocBlox_Parser_Abstract::$event_dispatcher = $dispatcher;
     DocBlox_Transformer_Abstract::$event_dispatcher = $dispatcher;
     DocBlox_Reflection_Abstract::$event_dispatcher = $dispatcher;
     try {
         $task->execute();
     } catch (Exception $e) {
         if (!$task->getQuiet()) {
             echo 'ERROR: ' . $e->getMessage() . PHP_EOL . PHP_EOL;
             echo $task->getUsageMessage();
         }
         die(1);
     }
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
ファイル: Docblox.php プロジェクト: toxygene/pants
 /**
  * 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;
 }
コード例 #4
0
 /**
  * Tests the debug method.
  *
  * It is expected that the `debug` method,
  *
  * * invokes the event dispatcher.
  *
  * @return void
  */
 public function testDebug()
 {
     // set up mocks for the dispatcher and the generated event.
     $event_dispatcher = $this->getMock('sfEventDispatcher', array('notify'));
     $event = $this->getMock('sfEvent', array('getReturnValue'), array($this->fixture, 'system.debug', array('message' => 'body')));
     // the event dispatcher's notify method will be invoken and return the
     // expected event
     $event_dispatcher->expects($this->once())->method('notify')->will($this->returnValue($event));
     // we will let the event return true to test whether the return value
     // is actually returned
     $event->expects($this->once())->method('getReturnValue')->will($this->returnValue(true));
     // test without setting the dispatcher
     DocBlox_Parser_Abstract::$event_dispatcher = $event_dispatcher;
     $this->fixture->debug('body');
 }