/** * This is the function that handles the files to be generated. * * @param string $views_dir This is the templates' directory, it contains * all the blade template needed * @param string $cache_dir This is used to cache templates generated from * blade compiler * @param string $template The template to use * @return void */ public function make($views_dir = __DIR__ . '/Resources/views', $cache_dir = __DIR . '/Resources/cache', $template = 'index') { $reader = Reader::createFromDefaults(); $docs = []; # iterate all classes and their functions foreach ($this->classes as $class => $functions) { # get the class annotations $anno_class = $reader->getClassAnnotations($class)->toArray(); if (!isset($anno_class['sleekdoc_init'])) { continue; } if (!isset($anno_class['sleekdoc_namespace'])) { throw new Exception("The annotation @sleekdoc_namespace must be declared in the class of {$class}."); } if (!isset($anno_class['sleekdoc_category'])) { throw new Exception("The annotation @sleekdoc_category must be declared in the class of {$class}."); } $namespace = $anno_class['sleekdoc_namespace']; $category = $anno_class['sleekdoc_category']; $this->data['api'][$category][$namespace] = $anno_class; # iterate each functions from the class foreach ($functions as $func) { $anno_method = $reader->getMethodAnnotations($class, $func)->toArray(); if (!isset($anno_method['sleekdoc_init'])) { continue; } $this->data['api'][$category][$namespace]['functions'][] = $anno_method; } } return static::blade($views_dir, $cache_dir)->make($template, ['data' => $this->data]); }
/** * @command.spec * _ _ * |_| | | * ___ _ __ _ | | ___ __ _ * / _ \ '_ \| | | |/ _ \_/ _` | * | __/ |_) | |_| | (_) _ (_| | * \___| .__/|_____|\___/ \__, | * | | __/ | * |_| |___/ * * Usage: * epilog <command> [<args>...] * * Commands are: * epilog watch Monitor a log files * epilog pretend Display a fake log stream, for testing only * * See 'epilog <command> -h' to read about a specific subcommand. * * Options: * -h --help Show this screen. * -v --version Show version. */ function epilog() { $specReader = AnnotationsReader::createFromDefaults(); $handler = new Handler(['version' => 'Epilog ' . Epilog::VERSION . ' by Márcio Almada', 'optionsFirst' => true]); $response = $handler->handle($specReader->getFunctionAnnotations(__FUNCTION__)->get('command.spec')); $command = __NAMESPACE__ . '\\' . $response['<command>']; if (!function_exists($command)) { throw new FlowException("Command `{$response['<command>']}` not defined, try epilog --help", 1); } $handler->optionsFirst = false; $response = $handler->handle($specReader->getFunctionAnnotations($command)->get('command.spec')); $command($response); }
/** * @return HttpMethod */ protected function getHandler() { return new HttpMethod(Reader::createFromDefaults()); }
protected function getReturnAnnotation(ReflectionMethod $method) { $annotationsBag = Reader::createFromDefaults()->getMethodAnnotations($method->class, $method->getName()); return $annotationsBag->get('return'); }
/** * @return Secure */ protected function getHandler() { return new Secure(Reader::createFromDefaults()); }
/** * Retrieves a reader object * * @return Minime\Annotations\Reader */ protected function reader() { if ($this->_reader === null) { $this->_reader = Reader::createFromDefaults(); } return $this->_reader; }
/** * @param $className * @return void */ private function __construct($className) { $this->reader = \Minime\Annotations\Reader::createFromDefaults(); $this->reflectionClass = new \ReflectionClass($className); $this->className = $className; }