Commit 6405c4f3 by Carsten Brandt

added proper word wrapping and note about read/writeonly properties

parent c5b42910
...@@ -82,7 +82,7 @@ class PhpDocController extends Controller ...@@ -82,7 +82,7 @@ class PhpDocController extends Controller
} }
if (!$ref->isSubclassOf('yii\base\Object') && $className != 'yii\base\Object') { if (!$ref->isSubclassOf('yii\base\Object') && $className != 'yii\base\Object') {
$this->stderr("[INFO] Skipping class $className as it is not a subclass of yii\\base\\Object\n", Console::FG_BLUE, Console::BOLD); $this->stderr("[INFO] Skipping class $className as it is not a subclass of yii\\base\\Object.\n", Console::FG_BLUE, Console::BOLD);
return false; return false;
} }
...@@ -92,7 +92,11 @@ class PhpDocController extends Controller ...@@ -92,7 +92,11 @@ class PhpDocController extends Controller
$seenSince = false; $seenSince = false;
$seenAuthor = false; $seenAuthor = false;
// TODO move these checks to different action
$lines = explode("\n", $newDoc); $lines = explode("\n", $newDoc);
if (trim($lines[1]) == '*' || substr(trim($lines[1]), 0, 3) == '* @') {
$this->stderr("[WARN] Class $className has no short description.\n", Console::FG_YELLOW, Console::BOLD);
}
foreach($lines as $line) { foreach($lines as $line) {
if (substr(trim($line), 0, 9) == '* @since ') { if (substr(trim($line), 0, 9) == '* @since ') {
$seenSince = true; $seenSince = true;
...@@ -218,11 +222,11 @@ class PhpDocController extends Controller ...@@ -218,11 +222,11 @@ class PhpDocController extends Controller
$className = $namespace . '\\' . $class['name']; $className = $namespace . '\\' . $class['name'];
$gets = $this->match( $gets = $this->match(
'#\* @return (?<type>\w+)(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' . '#\* @return (?<type>[\w\\|\\\\]+)(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' .
'[\s\n]{2,}public function (?<kind>get)(?<name>\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)#', '[\s\n]{2,}public function (?<kind>get)(?<name>\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)#',
$class['content']); $class['content']);
$sets = $this->match( $sets = $this->match(
'#\* @param (?<type>\w+) \$\w+(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' . '#\* @param (?<type>[\w\\|\\\\]+) \$\w+(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' .
'[\s\n]{2,}public function (?<kind>set)(?<name>\w+)\(\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)#', '[\s\n]{2,}public function (?<kind>set)(?<name>\w+)\(\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)#',
$class['content']); $class['content']);
$acrs = array_merge($gets, $sets); $acrs = array_merge($gets, $sets);
...@@ -247,14 +251,25 @@ class PhpDocController extends Controller ...@@ -247,14 +251,25 @@ class PhpDocController extends Controller
if (count($props) > 0) { if (count($props) > 0) {
$phpdoc .= " *\n"; $phpdoc .= " *\n";
foreach ($props as $propName => &$prop) { foreach ($props as $propName => &$prop) {
$phpdoc .= ' * @'; $docline = ' * @';
// if (isset($prop['get']) && isset($prop['set'])) // Few IDEs support complex syntax $docline .= 'property'; // Do not use property-read and property-write as few IDEs support complex syntax.
$phpdoc .= 'property'; if (isset($prop['get']) && isset($prop['set'])) {
// elseif (isset($prop['get'])) $note = '';
// $phpdoc .= 'property-read'; } elseif (isset($prop['get'])) {
// elseif (isset($prop['set'])) $note = ' This property is read-only.';
// $phpdoc .= 'property-write'; // $docline .= '-read';
$phpdoc .= ' ' . $this->getPropParam($prop, 'type') . " $$propName " . $this->getPropParam($prop, 'comment') . "\n"; } elseif (isset($prop['set'])) {
$note = ' This property is write-only.';
// $docline .= '-write';
}
$docline .= ' ' . $this->getPropParam($prop, 'type') . " $$propName ";
$comment = explode("\n", $this->getPropParam($prop, 'comment') . $note);
foreach ($comment as &$cline) {
$cline = ltrim($cline, '* ');
}
$docline = wordwrap($docline . implode(' ', $comment), 110, "\n * ") . "\n";
$phpdoc .= $docline;
} }
$phpdoc .= " *\n"; $phpdoc .= " *\n";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment