mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Added multilines support for description
This commit is contained in:
parent
33ff68b2e0
commit
8c0aa1d274
@ -180,9 +180,13 @@ class ApiDocExtractor
|
||||
protected function getData(ApiDoc $annotation, Route $route, \ReflectionMethod $method)
|
||||
{
|
||||
if (null === $annotation->getDescription()) {
|
||||
$comments = explode("\n", $this->getDocComment($method));
|
||||
$comments = explode("\n @", $this->getDocComment($method));
|
||||
// just set the first line
|
||||
$annotation->setDescription($comments[0]);
|
||||
$comment = trim($comments[0]);
|
||||
$comment = preg_replace("#[\n]+#", ' ', $comment);
|
||||
$comment = preg_replace('#[ ]+#', ' ', $comment);
|
||||
|
||||
$annotation->setDescription($comment);
|
||||
}
|
||||
|
||||
return array('annotation' => $annotation, 'route' => $route);
|
||||
|
@ -139,6 +139,9 @@ class ApiDocExtractorTest extends WebTestCase
|
||||
$data = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::myCommentedAction', 'test_route_5');
|
||||
|
||||
$this->assertNotNull($data);
|
||||
$this->assertEquals('This method is useful to test if the getDocComment works.', $data['annotation']->getDescription());
|
||||
$this->assertEquals(
|
||||
"This method is useful to test if the getDocComment works. And, it supports multilines until the first '@' char.",
|
||||
$data['annotation']->getDescription()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ class TestController
|
||||
|
||||
/**
|
||||
* This method is useful to test if the getDocComment works.
|
||||
* And, it supports multilines until the first '@' char.
|
||||
*
|
||||
* @ApiDoc()
|
||||
*/
|
||||
|
@ -109,7 +109,7 @@ _Action without HTTP verb_
|
||||
|
||||
### `ANY` /my-commented ###
|
||||
|
||||
_This method is useful to test if the getDocComment works._
|
||||
_This method is useful to test if the getDocComment works. And, it supports multilines until the first '@' char._
|
||||
MARKDOWN;
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -152,7 +152,7 @@ class SimpleFormatterTest extends WebTestCase
|
||||
'requirements' =>
|
||||
array(
|
||||
),
|
||||
'description' => 'This method is useful to test if the getDocComment works.',
|
||||
'description' => 'This method is useful to test if the getDocComment works. And, it supports multilines until the first \'@\' char.',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user