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 buildSettings(Repository $repository, Repository &$docsRepository = null, GitSource $source) { $class = new \ReflectionClass($this); $className = strtolower($class->getShortName()); $filename = $className . '.yml'; if (!file_exists($repository->getSourcesPath() . '/' . $filename)) { throw new \RuntimeException($filename . ' is missing, skip'); } $this->settings = Yaml::parse(file_get_contents($repository->getSourcesPath() . '/' . $filename)); if ($this->settings === null) { $this->settings = array(); } // use the master branch if (!empty($this->settings['branch'])) { $this->settings['src-branch'] = $this->settings['branch']; } else { if (empty($this->settings['branch'])) { $this->settings['src-branch'] = $repository->getMasterBranch(); } } # merge with defaults $this->settings = array_merge($this->defaultSettings, $this->settings); if (isset($this->settings['docs-repository'])) { list($ownerName, $repositoryName) = explode('/', $this->settings['docs-repository']); $docsRepository = clone $repository; $docsRepository->setOwnerName($ownerName); $docsRepository->setRepositoryName($repositoryName); } else { $docsRepository = $repository; } # build default base url if (!array_key_exists('base-url', $this->settings)) { $this->settings['base-url'] = $source->getPagesUrl($docsRepository); } # set default title if (!array_key_exists('title', $this->settings)) { $this->settings['title'] = $repository->getRepository(); } $this->logger->debug(sprintf('Build settings for %s/%s', $repository->getOwnerName(), $repository->getRepositoryName()), $this->settings); }