From f331d328a4f383df0c2f2d0fa966b25957a6494b Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sun, 26 May 2013 21:17:09 +0200 Subject: [PATCH] Export DocBlock & full description Add get/set for entire description, and create a docblock comment, based on the description/tags --- src/phpDocumentor/Reflection/DocBlock.php | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/phpDocumentor/Reflection/DocBlock.php b/src/phpDocumentor/Reflection/DocBlock.php index 9b6a97f..62fab1b 100644 --- a/src/phpDocumentor/Reflection/DocBlock.php +++ b/src/phpDocumentor/Reflection/DocBlock.php @@ -229,6 +229,29 @@ class DocBlock implements \Reflector $this->tags = $result; } + public function getDescription(){ + $short = $this->getShortDescription(); + $long = $this->getLongDescription()->getContents(); + + if($long){ + return $short . "\n" . $long; + }else{ + return $short; + } + } + + /** + * Set the short and long description. + * + * @param $docblock + * @return $this + */ + public function setDescription($docblock){ + list($short, $long) = $this->splitDocBlock($docblock); + $this->short_description = $short; + $this->long_description = new DocBlock\Description($long, $this); + return $this; + } /** * Returns the opening line or also known as short description. * @@ -348,6 +371,27 @@ class DocBlock implements \Reflector return $tag; } + /** + * Generate a DocBlock Comment + * + * @return string + */ + public function getDocComment($indentation = ''){ + + $description = str_replace("\n", "\n$indentation * ", $this->getDescription()); + + $comment = "$indentation/**\n$indentation * $description\n$indentation *\n"; + + /** @var Tag $tag */ + foreach ($this->getTags() as $tag) { + $comment .= $indentation.' * @'. $tag->getName() . " " . $tag->getContent() . "\n"; + } + + $comment .= $indentation.' */'; + + return $comment; + } + /** * Builds a string representation of this object. *