Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensuring full docblocks are presented in console `Help` command for b…

…oth classes and methods. Misc. code cleanup.
  • Loading branch information...
commit c8545ff5c10fa88e0cdc42a8907c3361bee1da4f 1 parent 49f5692
@nateabele nateabele authored
View
2  console/Command.php
@@ -420,4 +420,4 @@ protected function _response($type, $string, $options) {
}
}
-?>
+?>
View
22 console/command/Help.php
@@ -88,7 +88,7 @@ public function run($command = null) {
}
/**
- * Get the api for the class.
+ * Gets the API for the class.
*
* @param string $class fully namespaced class in dot notation.
* @param string $type method|property
@@ -102,8 +102,8 @@ public function api($class = null, $type = null, $name = null) {
default:
$info = Inspector::info($class);
$result = array('class' => array(
- 'name' => Inflector::classify($info['shortName']),
- 'description' => $info['description']
+ 'name' => $info['shortName'],
+ 'description' => trim($info['description'] . PHP_EOL . PHP_EOL . $info['text'])
));
break;
case 'method':
@@ -288,13 +288,9 @@ protected function _renderUsage($command, $method, $properties = array()) {
$args = array_reduce($method['args'], function($a, $b) {
return "{$a} {$b['usage']}";
});
- $this->out($this->_pad(sprintf(
- "{:command}li3 %s%s{:end}{:command}%s{:end}{:option}%s{:end}",
- $command ?: 'COMMAND',
- $method['name'] == 'run' ? '' : " {$method['name']}",
- $params,
- $args
- )));
+ $format = "{:command}li3 %s%s{:end}{:command}%s{:end}{:option}%s{:end}";
+ $name = $method['name'] == 'run' ? '' : " {$method['name']}";
+ $this->out($this->_pad(sprintf($format, $command ?: 'COMMAND', $name, $params, $args)));
}
/**
@@ -305,7 +301,9 @@ protected function _renderUsage($command, $method, $properties = array()) {
*/
protected function _renderDescription($info) {
$this->out('DESCRIPTION', 'heading');
- $this->out($this->_pad(strtok($info['description'], "\n"), 1));
+ $break = PHP_EOL . PHP_EOL;
+ $description = trim("{$info['description']}{$break}{$info['text']}");
+ $this->out($this->_pad($description, PHP_EOL));
}
/**
@@ -321,4 +319,4 @@ protected function _pad($message, $level = 1) {
}
}
-?>
+?>
View
23 tests/cases/console/command/HelpTest.php
@@ -84,10 +84,23 @@ public function testRunWithName() {
$this->assertPattern("/{$expected}/", $result);
}
+ /**
+ * Tests that class and method help includes detailed descriptions as well as summary text.
+ */
+ public function testDocsIncludeDescription() {
+ $command = new Help(array('request' => $this->request, 'classes' => $this->classes));
+
+ $this->assertNull($command->api('lithium.core.Libraries'));
+ $this->assertPattern('/Auto-loading classes/', $command->response->output);
+
+ $command = new Help(array('request' => $this->request, 'classes' => $this->classes));
+
+ $this->assertNull($command->api('lithium.core.Libraries::add'));
+ $this->assertPattern('/Adding libraries/', $command->response->output);
+ }
+
public function testApiClass() {
- $command = new Help(array(
- 'request' => $this->request, 'classes' => $this->classes
- ));
+ $command = new Help(array('request' => $this->request, 'classes' => $this->classes));
$result = $command->api('lithium.util.Inflector');
$this->assertNull($result);
@@ -98,9 +111,7 @@ public function testApiClass() {
}
public function testApiMethod() {
- $command = new Help(array(
- 'request' => $this->request, 'classes' => $this->classes
- ));
+ $command = new Help(array('request' => $this->request, 'classes' => $this->classes));
$result = $command->api('lithium.util.Inflector', 'method');
$this->assertNull($result);
Please sign in to comment.
Something went wrong with that request. Please try again.