Пример #1
0
 public function run(Repository $repository, GitSource $source)
 {
     $this->logger = new Logger($repository->getRepository(), array($this->handler));
     $this->logger->info(sprintf('Generate api docs for %s/%s, branch %s: %s', $repository->getOwnerName(), $repository->getRepositoryName(), $repository->getCommitBranch(), $repository->getCommitMessage()));
     $this->generateDocs($repository, $source);
 }
 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);
 }