/** * Generate markdown documentation. * * @param Structure $structure The structure * @param string $outputPath The directory path where to put markdown documentation * * @throws DocMdException * @throws \Twig_Error_Loader * @throws \Twig_Error_Runtime * @throws \Twig_Error_Syntax */ protected function generateDocs(Structure $structure, $outputPath) { foreach ($structure->getFiles() as $file) { $class = $file->getClass(); $classFullName = $class->getFullName(); if (in_array($classFullName, $this->config['exclude'])) { continue; } $this->classes[$classFullName] = $class; switch ($class->getClassType()) { case File::TYPE_CLASS: $this->index['classes'][] = Tools::getFileLink($classFullName); break; case File::TYPE_INTERFACE: $this->index['interfaces'][] = Tools::getFileLink($classFullName); break; case File::TYPE_TRAIT: $this->index['traits'][] = Tools::getFileLink($classFullName); break; } } $loader = new Twig_Loader_Filesystem($this->tplDir); $twig = new Twig_Environment($loader); foreach ($this->classes as $class) { $doc = $twig->render('class.txt', ['class' => $class]); file_put_contents($outputPath . DIRECTORY_SEPARATOR . $class->getMdFileName(), $doc); } $twig = new Twig_Environment($loader); $doc = $twig->render('index.txt', ['classes' => $this->index['classes'], 'interfaces' => $this->index['interfaces'], 'traits' => $this->index['traits'], 'projectName' => $this->config['project_name']]); file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'index.md', $doc); }
/** * Return long element description. * * @return string */ public function getLongDescription() { return Tools::fixDesc('' . $this->elem->docblock->{'long-description'}); }
/** * Method return type. * * @param bool $link Set to true to create link to other markdown document if possible * * @return string */ public function getReturnPhpType($link = true) { $this->getTags(); return $this->return ? Tools::fixTypeHint($this->return->getPhpTypeProp($link)) : ''; }