/** * @param State $state * @param Logger $logger * * @throws \RuntimeException */ public function run(State $state, Logger $logger) { $logger->log(0, 'run pre processors'); foreach ($state->config->getPreProcessors() as $processor) { $logger->log(1, get_class($processor)); $processor->run($state, $logger); } }
/** * @param State $state * @param Logger $logger * * @throws RuntimeException * @throws MarkupException */ public function run(State $state, Logger $logger) { $state->annotations; $state->classes; $dir = realpath($state->config->getExportDir()); if (!$dir) { throw new RuntimeException('export dir does not exist'); } $exportFile = $dir . '/' . $this->file; $logger->log(0, sprintf('save parsed result to %s', $exportFile)); $content = print_r($state->classes, true) . PHP_EOL . print_r($state->annotations, true); file_put_contents($exportFile, $content); }
/** * @param State $state * @param Logger $logger * * @throws \RuntimeException */ public function run(State $state, Logger $logger) { $codeParser = new CodeParser(); $cacheDir = $state->config->getCacheDir(); $cacheNote = $cacheDir ? 'cache at ' . $cacheDir : 'cache disabled'; $logger->log(0, sprintf('parse class dirs (%s)', $cacheNote)); $classes = $codeParser->parse($state->config->getClassDirs(), $state->config->getCacheDir()); if ($logger->hasDepth(1)) { foreach ($classes as $class) { $logger->log(1, sprintf('found class <cyan>%s<reset> in %s', $class->name, $class->fileName)); } } $state->classes = $classes; }
/** * @param State $state * @param Logger $logger * * @throws RuntimeException * @throws MarkupException */ public function run(State $state, Logger $logger) { $filesystem = new Filesystem(); $from = realpath($state->config->getExportDir()); if (!$from) { throw new MarkupException('export dir does not exist'); } if (!$this->destination) { throw new MarkupException('destination no set'); } $to = $state->config->getBaseDir() . '/' . $this->destination; if ($this->purge) { $filesystem->purge($to); } $logger->log(0, sprintf('mirror export dir (%s -> %s)', $from, $to)); $filesystem->copy($from, $to); }
/** * @param State $state * @param Logger $logger * * @throws \RuntimeException */ public function run(State $state, Logger $logger) { $filesystem = new Filesystem(); $docsDir = $state->config->getDocsDir(); $exportDir = $state->config->getExportDir(); $filesystem->ensureDir($exportDir); if ($docsDir === null) { $logger->log(0, 'skip copying docs to export dir (no docs dir configured)'); return; } $docsDir = realpath($docsDir); if ($docsDir === false) { $logger->log(0, 'skip copying docs to export dir (docs dir docs dir does not exist)'); return; } $logger->log(0, sprintf('copy docs to export dir (%s -> %s)', $docsDir, $exportDir)); $filesystem->mirror($docsDir, $exportDir); }
/** * @param State $state * @param Logger $logger * * @throws RuntimeException * @throws InvalidArgumentException * @throws AnnotationException */ public function run(State $state, Logger $logger) { $annotationParser = new AnnotationParser(new DocParser()); $logger->log(0, 'parse annotations'); foreach ($state->config->getAnnotationNamespaces() as $namespace) { $annotationParser->registerNamespace($namespace); } foreach ($state->classes as $class) { try { $annotations = $annotationParser->parse($class); } catch (Exception $ex) { throw new AnnotationException(sprintf('failed to parse annotations of class %s. %s', $class->name, $ex->getMessage())); } $logger->log(1, sprintf('of class %s', $class->name)); foreach ($annotations as $annotation) { $logger->log(2, sprintf('found: <cyan>%s<reset>', get_class($annotation))); $state->annotations[] = $annotation; } } }
/** * @param Parsable $parsable * @param string $path * @param State $state * @param Logger $logger * * @return string * @throws MarkupException */ private function replaceMarkupsInParsable(Parsable $parsable, $path, State $state, Logger $logger) { $logger->log(1, sprintf('replace markups in <yellow>result of <cyan>%s<reset>', $path)); $context = $this->markupParser->parseContent($parsable->text, $path); return $this->replaceMarkupsInContent($parsable->text, $context, $state, $logger, false); }