From: scribu Date: Thu, 1 Aug 2013 20:18:57 +0000 (+0300) Subject: DocParser: remove decorations before processing X-Git-Tag: v0.11.0~7^2~9 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4efa6555190d2050455115bfb8da9f67119252c9;p=wvm%2Fwvm.git DocParser: remove decorations before processing --- diff --git a/php/WP_CLI/DocParser.php b/php/WP_CLI/DocParser.php index f830285e..ebd9a529 100644 --- a/php/WP_CLI/DocParser.php +++ b/php/WP_CLI/DocParser.php @@ -7,11 +7,19 @@ class DocParser { protected $docComment; function __construct( $docComment ) { - $this->docComment = $docComment; + $this->docComment = self::remove_decorations( $docComment ); + } + + private static function remove_decorations( $comment ) { + $comment = preg_replace( '|^/\*\*\n|', '', $comment ); + $comment = preg_replace( '|\n[\t ]*\*/$|', '', $comment ); + $comment = preg_replace( '|^[\t ]*\* ?|m', '', $comment ); + + return $comment; } function get_shortdesc() { - if ( !preg_match( '/\* (\w.+)\n*/', $this->docComment, $matches ) ) + if ( !preg_match( '|^([^@][^\n]+)\n*|', $this->docComment, $matches ) ) return false; return $matches[1]; @@ -22,14 +30,14 @@ class DocParser { } function get_tag( $name ) { - if ( preg_match( '/@' . $name . '\s+([a-z-_]+)/', $this->docComment, $matches ) ) + if ( preg_match( '|^@' . $name . '\s+([a-z-_]+)|m', $this->docComment, $matches ) ) return $matches[1]; return false; } function get_synopsis() { - if ( !preg_match( '/@synopsis\s+([^\n]+)/', $this->docComment, $matches ) ) + if ( !preg_match( '|^@synopsis\s+(.+)|m', $this->docComment, $matches ) ) return false; return $matches[1];