protected function generateDocs(Repository $repository, Repository $docsRepository, GitSource $source) { $this->logger->debug('Generate docs'); $args = array(dirname(dirname(__DIR__)) . '/vendor/bin/apigen'); $args[] = 'generate'; foreach (array('config' => static::PARAM_SOURCE_FILE, 'template-config' => static::PARAM_SOURCE_FILE, 'extensions' => static::PARAM_STRING, 'exclude' => static::PARAM_STRING, 'skip-doc-path' => static::PARAM_STRING, 'main' => static::PARAM_STRING, 'title' => static::PARAM_STRING, 'base-url' => static::PARAM_STRING, 'google-cse-id' => static::PARAM_STRING, 'google-analytics' => static::PARAM_STRING, 'template-theme' => static::PARAM_STRING, 'groups' => static::PARAM_STRING, 'charset' => static::PARAM_STRING, 'access-levels' => static::PARAM_STRING, 'annotation-groups' => static::PARAM_STRING, 'internal' => static::PARAM_BOOL, 'php' => static::PARAM_BOOL, 'tree' => static::PARAM_BOOL, 'deprecated' => static::PARAM_BOOL, 'no-source-code' => static::PARAM_BOOL, 'todo' => static::PARAM_BOOL, 'download' => static::PARAM_BOOL) as $parameter => $type) { if (array_key_exists($parameter, $this->settings)) { $value = $this->settings[$parameter]; switch ($type) { case static::PARAM_SOURCE_FILE: $value = $repository->getSourcesPath() . '/' . ltrim($value, '/'); break; case static::PARAM_DOCS_FILE: $value = $repository->getDocsPath() . '/' . ltrim($value, '/'); break; case static::PARAM_STRING: // do nothing break; case static::PARAM_BOOL: if ($value) { $args[] = '--' . $parameter; } continue 2; default: $this->logger->warning(sprintf('Parameter %s has an illegal type %s', $parameter, $type)); // skip continue; } $args[] = '--' . $parameter; $args[] = $value; } } $args[] = '--source'; $args[] = $repository->getSourcesPath() . (array_key_exists('src-path', $this->settings) ? '/' . ltrim($this->settings['src-path'], '/') : ''); $args[] = '--destination'; $args[] = $docsRepository->getDocsPath() . (array_key_exists('docs-path', $this->settings) ? '/' . ltrim($this->settings['docs-path'], '/') : ''); $process = ProcessBuilder::create($args)->getProcess(); $process->setTimeout(null); $this->logger->debug('exec ' . $process->getCommandLine()); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput()); } }
protected function generateDocs(Repository $repository, Repository $docsRepository, GitSource $source) { $this->logger->debug('Generate docs'); $args = array(dirname(dirname(__DIR__)) . '/vendor/bin/phpdoc.php'); foreach (array('config' => static::PARAM_SOURCE_FILE, 'extensions' => static::PARAM_STRING, 'ignore' => static::PARAM_STRING, 'ignore-tags' => static::PARAM_STRING, 'encoding' => static::PARAM_STRING, 'title' => static::PARAM_STRING, 'defaultpackagename' => static::PARAM_STRING, 'template' => static::PARAM_STRING, 'hidden' => static::PARAM_BOOL, 'ignore-symlinks' => static::PARAM_BOOL, 'visibility' => static::PARAM_STRING, 'sourcecode' => static::PARAM_BOOL, 'parseprivate' => static::PARAM_BOOL) as $parameter => $type) { if (array_key_exists($parameter, $this->settings)) { $value = $this->settings[$parameter]; switch ($type) { case static::PARAM_SOURCE_FILE: $value = $repository->getSourcesPath() . '/' . ltrim($value, '/'); break; case static::PARAM_DOCS_FILE: $value = $repository->getDocsPath() . '/' . ltrim($value, '/'); break; case static::PARAM_STRING: // do nothing break; case static::PARAM_BOOL: if ($value) { $args[] = '--' . $parameter; } continue 2; default: $this->logger->warning(sprintf('Parameter %s has an illegal type %s', $parameter, $type)); // skip continue 2; } $args[] = '--' . $parameter . '=' . $value; } } $args[] = '--directory'; $args[] = $repository->getSourcesPath() . (array_key_exists('src-path', $this->settings) ? '/' . ltrim($this->settings['src-path'], '/') : ''); $args[] = '--target'; $args[] = $docsRepository->getDocsPath() . (array_key_exists('docs-path', $this->settings) ? '/' . ltrim($this->settings['docs-path'], '/') : ''); $args[] = '--force'; $args[] = '--no-interaction'; $process = ProcessBuilder::create($args)->getProcess(); $this->logger->debug('exec ' . $process->getCommandLine()); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput()); } }
protected function pushDocs(Repository $repository, Repository $docsRepository, GitSource $source) { $this->logger->debug('Push docs'); $process = ProcessBuilder::create(array('git', 'status', '-s'))->setWorkingDirectory($docsRepository->getDocsPath())->getProcess(); $this->logger->debug('exec ' . $process->getCommandLine()); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput()); } $changes = $process->getOutput(); if ($changes) { $changes = explode("\n", $changes); $changes = array_map('trim', $changes); $changes = array_filter($changes); foreach ($changes as $change) { list($status, $file) = explode(' ', $change, 2); $process = ProcessBuilder::create(array('git', $status == 'D' ? 'rm' : 'add', $file))->setWorkingDirectory($docsRepository->getDocsPath())->getProcess(); $this->logger->debug('exec ' . $process->getCommandLine()); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput()); } } $process = ProcessBuilder::create(array('git', 'commit', '-m', $repository->getCommitMessage()))->setWorkingDirectory($docsRepository->getDocsPath())->getProcess(); $this->logger->debug('exec ' . $process->getCommandLine()); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput()); } } $process = ProcessBuilder::create(array('git', 'push', 'origin', $this->settings['docs-branch']))->setWorkingDirectory($docsRepository->getDocsPath())->getProcess(); $this->logger->debug('exec ' . $process->getCommandLine()); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getCommandLine() . ': ' . $process->getErrorOutput() ?: $process->getOutput()); } }