From 201dbaed57e7c18dbf440935918728043882fa3a Mon Sep 17 00:00:00 2001 From: Francois Zaninotto Date: Sat, 15 Oct 2011 20:44:52 +0200 Subject: [PATCH] No need to look for phpDoc to get an exemple output for methods that generate output at will --- src/Documentor.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Documentor.php b/src/Documentor.php index b78c243c..4a3ea896 100644 --- a/src/Documentor.php +++ b/src/Documentor.php @@ -19,16 +19,18 @@ class Documentor $formatters[$providerClass] = array(); $refl = new \ReflectionObject($provider); foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflmethod) { - if ($reflmethod->name == '__construct') { + $methodName = $reflmethod->name; + if ($methodName == '__construct') { continue; } - $comment = $reflmethod->getDocComment(); - if (preg_match('/^\s+\*\s+@example\s+(.*)$/mi', $comment, $matches)) { - $example = $matches[1]; - } else { - $example = ''; + $example = $this->generator->format($methodName); + if (is_array($example)) { + $example = 'array('. join(', ', $example) . ')'; } - $formatters[$providerClass][$reflmethod->name] = $example; + if (is_string($example)) { + $example = var_export($example, true); + } + $formatters[$providerClass][$methodName] = $example; } ksort($formatters[$providerClass]); }