Skip to content

Commit d57128e

Browse files
committed
Export DocBlock & full description
Add get/set for entire description, and create a docblock comment, based on the description/tags
1 parent d9c0928 commit d57128e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/phpDocumentor/Reflection/DocBlock.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,29 @@ protected function parseTags($tags)
229229
$this->tags = $result;
230230
}
231231

232+
public function getDescription(){
233+
$short = $this->getShortDescription();
234+
$long = $this->getLongDescription()->getContents();
235+
236+
if($long){
237+
return $short . "\n" . $long;
238+
}else{
239+
return $short;
240+
}
241+
}
242+
243+
/**
244+
* Set the short and long description.
245+
*
246+
* @param $docblock
247+
* @return $this
248+
*/
249+
public function setDescription($docblock){
250+
list($short, $long) = $this->splitDocBlock($docblock);
251+
$this->short_description = $short;
252+
$this->long_description = new DocBlock\Description($long, $this);
253+
return $this;
254+
}
232255
/**
233256
* Returns the opening line or also known as short description.
234257
*
@@ -348,6 +371,27 @@ public function appendTag(Tag $tag)
348371
return $tag;
349372
}
350373

374+
/**
375+
* Generate a DocBlock Comment
376+
*
377+
* @return string
378+
*/
379+
public function getDocComment($indentation = ''){
380+
381+
$description = str_replace("\n", "\n$indentation * ", $this->getDescription());
382+
383+
$comment = "$indentation/**\n$indentation * $description\n$indentation *\n";
384+
385+
/** @var Tag $tag */
386+
foreach ($this->getTags() as $tag) {
387+
$comment .= $indentation.' * @'. $tag->getName() . " " . $tag->getContent() . "\n";
388+
}
389+
390+
$comment .= $indentation.' */';
391+
392+
return $comment;
393+
}
394+
351395
/**
352396
* Builds a string representation of this object.
353397
*

0 commit comments

Comments
 (0)