コード例 #1
0
 /**
  * @param ReflectionElement $element
  * @return string
  */
 private function getElementLinesAnchor(ReflectionElement $element)
 {
     $anchor = '#' . $element->getStartLine();
     if ($element->getStartLine() !== $element->getEndLine()) {
         $anchor .= '-' . $element->getEndLine();
     }
     return $anchor;
 }
コード例 #2
0
 /**
  * @return Template
  */
 public function loadTemplateWithElementNamespaceOrPackage(Template $template, ReflectionElement $element)
 {
     if ($namespaces = $this->elementStorage->getNamespaces()) {
         $name = $element->getPseudoNamespaceName();
         $template = $this->loadTemplateWithNamespace($template, $name, $namespaces[$name]);
     } elseif ($packages = $this->elementStorage->getPackages()) {
         $name = $element->getPseudoPackageName();
         $template = $this->loadTemplateWithNamespace($template, $name, $packages[$name]);
     }
     return $template;
 }
コード例 #3
0
 /**
  * @param ReflectionMethod|ReflectionProperty $reflection
  * @return string
  */
 private function getPropertyOrMethodFqnName(ReflectionElement $reflection)
 {
     return $reflection->getDeclaringClassName() . '::' . $reflection->getName();
 }
コード例 #4
0
 /**
  * @param string $definition
  * @param ReflectionElement $reflectionElement
  * @return ReflectionClass|ReflectionConstant|ReflectionFunction|NULL
  */
 private function resolveIfParsed($definition, ReflectionElement $reflectionElement)
 {
     $definition = $this->removeEndBrackets($definition);
     if ($class = $this->getClass($definition, $reflectionElement->getNamespaceName())) {
         return $class;
     } elseif ($constant = $this->getConstant($definition, $reflectionElement->getNamespaceName())) {
         return $constant;
     } elseif ($function = $this->getFunction($definition, $reflectionElement->getNamespaceName())) {
         return $function;
     }
     return NULL;
 }
コード例 #5
0
 /**
  * @return bool
  */
 public function isDocumented()
 {
     if ($this->isDocumented === NULL && parent::isDocumented() && $this->reflection->getDeclaringClassName() === NULL) {
         $fileName = $this->reflection->getFilename();
         $skipDocPath = $this->configuration->getOption(CO::SKIP_DOC_PATH);
         foreach ($skipDocPath as $mask) {
             if (fnmatch($mask, $fileName, FNM_NOESCAPE)) {
                 $this->isDocumented = FALSE;
                 break;
             }
         }
     }
     return $this->isDocumented;
 }
コード例 #6
0
ファイル: Template.php プロジェクト: sirone/apigen
 /**
  * Returns a link to a element source code.
  *
  * @param \ApiGen\Reflection\ReflectionElement $element Element reflection
  * @param boolean $withLine Include file line number into the link
  * @return string
  */
 public function getSourceUrl(Reflection\ReflectionElement $element, $withLine = true)
 {
     if ($element instanceof Reflection\ReflectionClass || $element instanceof Reflection\ReflectionFunction || $element instanceof Reflection\ReflectionConstant && null === $element->getDeclaringClassName()) {
         $elementName = $element->getName();
         if ($element instanceof Reflection\ReflectionClass) {
             $file = 'class-';
         } elseif ($element instanceof Reflection\ReflectionConstant) {
             $file = 'constant-';
         } elseif ($element instanceof Reflection\ReflectionFunction) {
             $file = 'function-';
         }
     } else {
         $elementName = $element->getDeclaringClassName();
         $file = 'class-';
     }
     $file .= $this->urlize($elementName);
     $lines = null;
     if ($withLine) {
         $lines = $element->getStartLine() !== $element->getEndLine() ? sprintf('%s-%s', $element->getStartLine(), $element->getEndLine()) : $element->getStartLine();
     }
     return sprintf($this->config->template->templates->main->source->filename, $file) . (null !== $lines ? '#' . $lines : '');
 }
コード例 #7
0
 /**
  * @return string
  */
 public function longDescription(ReflectionElement $element)
 {
     $long = $element->getLongDescription();
     // Merge lines
     $long = preg_replace_callback('~(?:<(code|pre)>.+?</\\1>)|([^<]*)~s', function ($matches) {
         return !empty($matches[2]) ? preg_replace('~\\n(?:\\t|[ ])+~', ' ', $matches[2]) : $matches[0];
     }, $long);
     return $this->doc($long, $element, TRUE);
 }
コード例 #8
0
 private function loadUsesToReferencedElementUsedby(ReflectionElement $element)
 {
     $uses = $element->getAnnotation('uses');
     if ($uses === NULL) {
         return;
     }
     foreach ($uses as $value) {
         list($link, $description) = preg_split('~\\s+|$~', $value, 2);
         $resolved = $this->elementResolver->resolveElement($link, $element);
         if ($resolved) {
             $resolved->addAnnotation('usedby', $element->getPrettyName() . ' ' . $description);
         }
     }
 }
コード例 #9
0
 /**
  * @param ReflectionElement|string $element
  * @return string
  */
 private function detectClass($element)
 {
     if ($element instanceof ReflectionClass) {
         return $element;
     }
     if ($element instanceof ReflectionMethod || $element instanceof ReflectionProperty || $element instanceof ReflectionConstant) {
         return $element->getDeclaringClass();
     }
     return '';
 }
コード例 #10
0
 /**
  * @return string
  */
 private function getHighlightedCodeFromElement(ReflectionElement $element)
 {
     $content = $this->charsetConvertor->convertFileToUtf($element->getFileName());
     return $this->sourceCodeHighlighter->highlightAndAddLineNumbers($content);
 }
コード例 #11
0
 /**
  * Returns if the class should be documented.
  *
  * @return boolean
  */
 public function isDocumented()
 {
     if (null === $this->isDocumented && parent::isDocumented()) {
         $fileName = self::$generator->unPharPath($this->reflection->getFilename());
         foreach (self::$config->skipDocPath as $mask) {
             if (fnmatch($mask, $fileName, FNM_NOESCAPE)) {
                 $this->isDocumented = false;
                 break;
             }
         }
         if (true === $this->isDocumented) {
             foreach (self::$config->skipDocPrefix as $prefix) {
                 if (0 === strpos($this->reflection->getName(), $prefix)) {
                     $this->isDocumented = false;
                     break;
                 }
             }
         }
     }
     return $this->isDocumented;
 }