Exemplo n.º 1
0
 /**
  * Execute the action.
  * @param array $args command line parameters specific for this command
  */
 public function run($args)
 {
     if (is_file($composerAutoload = __DIR__ . '/../../vendor/autoload.php')) {
         require $composerAutoload;
     }
     $options = array('fileTypes' => array('php'), 'exclude' => array('.gitignore', '/yiilite.php', '/yiit.php', '/cli', '/i18n/data', '/messages', '/vendors', '/views', '/web/js', '/web/widgets/views', '/utils/mimeTypes.php', '/gii/assets', '/gii/components', '/gii/controllers', '/gii/generators', '/gii/models', '/gii/views'));
     if (!isset($args[0])) {
         $this->usageError('the output directory is not specified.');
     }
     if ($args[0] == 'check') {
         $checkFiles = CFileHelper::findFiles(YII_PATH, $options);
         $model = new ApiModel();
         $model->check($checkFiles);
         exit;
     }
     if (!is_dir($docPath = $args[0])) {
         $this->usageError("the output directory {$docPath} does not exist.");
     }
     $offline = true;
     if (isset($args[1]) && $args[1] === 'online') {
         $offline = false;
     }
     $this->version = Yii::getVersion();
     /*
      * development version - link to master
      * release version link to tags
      */
     if (substr($this->version, -3) == 'dev') {
         $this->baseSourceUrl .= '/master/framework';
     } else {
         $this->baseSourceUrl .= '/' . $this->version . '/framework';
     }
     $this->pageTitle = 'Yii Framework Class Reference';
     $themePath = dirname(__FILE__) . '/api';
     echo "\nBuilding.. : " . $this->pageTitle . "\n";
     echo "Type...... : " . ($offline ? "offline" : "online") . "\n";
     echo "Version... : " . $this->version . "\n";
     echo "Source URL : " . $this->baseSourceUrl . "\n\n";
     echo "Building model...\n";
     $model = $this->buildModel(YII_PATH, $options);
     $this->classes = $model->classes;
     $this->packages = $model->packages;
     echo "Building pages...\n";
     if ($offline) {
         $this->buildOfflinePages($docPath . DIRECTORY_SEPARATOR . 'api', $themePath);
     } else {
         $this->buildOnlinePages($docPath . DIRECTORY_SEPARATOR . 'api', $themePath);
         $this->buildKeywords($docPath);
         $this->buildPackages($docPath);
     }
     echo "Done.\n\n";
 }