From fce0f5d5a6f173905cfa99c2438fefa57048b6f4 Mon Sep 17 00:00:00 2001 From: William DURAND Date: Fri, 13 Jul 2012 15:26:36 +0200 Subject: [PATCH] Fix extractor, markdown formatter, and tests --- Extractor/ApiDocExtractor.php | 6 +++--- Formatter/MarkdownFormatter.php | 6 ++++-- Tests/Formatter/MarkdownFormatterTest.php | 5 ----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index be3b82b..cddfe40 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -227,14 +227,14 @@ class ApiDocExtractor { $comment = $reflected->getDocComment(); + // Remove PHPDoc + $comment = preg_replace('/^\s+\* @[\w0-9]+.*/msi', '', $comment); + // let's clean the doc block $comment = str_replace('/**', '', $comment); $comment = str_replace('*/', '', $comment); $comment = preg_replace('/^\s*\* ?/m', '', $comment); - // Remove everything (and including) first annotation - $comment = preg_replace('/@[\w0-9]+\(.*/msi', '', $comment); - return trim($comment); } } diff --git a/Formatter/MarkdownFormatter.php b/Formatter/MarkdownFormatter.php index de9ec24..cc4270e 100644 --- a/Formatter/MarkdownFormatter.php +++ b/Formatter/MarkdownFormatter.php @@ -27,8 +27,10 @@ class MarkdownFormatter extends AbstractFormatter $markdown .= "\n\n"; if (isset($data['documentation']) && !empty($data['documentation'])) { - $markdown .= $data['documentation']; - $markdown .= "\n\n"; + if (isset($data['description']) && 0 === strcmp($data['description'], $data['documentation'])) { + $markdown .= $data['documentation']; + $markdown .= "\n\n"; + } } if (isset($data['requirements']) && !empty($data['requirements'])) { diff --git a/Tests/Formatter/MarkdownFormatterTest.php b/Tests/Formatter/MarkdownFormatterTest.php index 2e18a5a..a2ae4f3 100644 --- a/Tests/Formatter/MarkdownFormatterTest.php +++ b/Tests/Formatter/MarkdownFormatterTest.php @@ -126,11 +126,6 @@ _Action without HTTP verb_ _This method is useful to test if the getDocComment works. And, it supports multilines until the first '@' char._ -#### Documentation #### - - This method is useful to test if the getDocComment works. - And, it supports multilines until the first '@' char. - #### Requirements #### **id**