From ec0abbaac0b9947872c38b0e0f50712c6c5b6f24 Mon Sep 17 00:00:00 2001 From: brego Date: Wed, 18 May 2005 10:11:28 +0000 Subject: [PATCH] Some docblock formatting changes, and /libs/bake.php - takes time, but domumenting is very educating :) git-svn-id: https://svn.cakephp.org/repo/trunk/cake@140 3807eeeb-6ff5-0310-8944-8be069107fe0 --- app/app_controller.php | 47 +++-- app/app_model.php | 47 +++-- config/core.php | 30 +-- config/database.php.default | 36 ++-- config/paths.php | 28 +-- config/routes.php | 34 ++-- config/routes.php.default | 34 ++-- config/tags.php | 30 +-- libs/bake.php | 391 ++++++++++++++++++++++-------------- 9 files changed, 381 insertions(+), 296 deletions(-) diff --git a/app/app_controller.php b/app/app_controller.php index 2427ea69e..7cbb91384 100644 --- a/app/app_controller.php +++ b/app/app_controller.php @@ -14,32 +14,31 @@ ////////////////////////////////////////////////////////////////////////// /** - * Purpose: AppController - * This file is application-wide controller file. You can put all - * application-wide controller-related methods here. - * - * @filesource - * @author Cake Authors/Developers - * @copyright Copyright (c) 2005, Cake Authors/Developers - * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers - * @package cake - * @subpackage cake.app - * @since Cake v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ + * This file is application-wide controller file. You can put all + * application-wide controller-related methods here. + * + * @filesource + * @author Cake Authors/Developers + * @copyright Copyright (c) 2005, Cake Authors/Developers + * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers + * @package cake + * @subpackage cake.app + * @since Cake v 0.2.9 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ /** - * Add your application-wide methods in the class below, your controllers - * will be inheriting them. - * - * @package cake - * @subpackage cake.app - * @since Cake v 0.2.9 - * - */ + * Add your application-wide methods in the class below, your controllers + * will be inheriting them. + * + * @package cake + * @subpackage cake.app + * @since Cake v 0.2.9 + * + */ class AppController extends Controller { } diff --git a/app/app_model.php b/app/app_model.php index d344e0189..058db2fa4 100644 --- a/app/app_model.php +++ b/app/app_model.php @@ -14,32 +14,31 @@ ////////////////////////////////////////////////////////////////////////// /** - * Purpose: AppModel - * This file is application-wide model file. You can put all - * application-wide model-related methods here. - * - * @filesource - * @author Cake Authors/Developers - * @copyright Copyright (c) 2005, Cake Authors/Developers - * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers - * @package cake - * @subpackage cake.app - * @since Cake v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ + * This file is application-wide model file. You can put all + * application-wide model-related methods here. + * + * @filesource + * @author Cake Authors/Developers + * @copyright Copyright (c) 2005, Cake Authors/Developers + * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers + * @package cake + * @subpackage cake.app + * @since Cake v 0.2.9 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ /** - * Add your application-wide methods in the class below, your models - * will be inheriting them. - * - * @package cake - * @subpackage cake.app - * @since Cake v 0.2.9 - * - */ + * Add your application-wide methods in the class below, your models + * will be inheriting them. + * + * @package cake + * @subpackage cake.app + * @since Cake v 0.2.9 + * + */ class AppModel extends Model { } diff --git a/config/core.php b/config/core.php index 5ba8ec071..117b7dd3c 100644 --- a/config/core.php +++ b/config/core.php @@ -14,21 +14,21 @@ ////////////////////////////////////////////////////////////////////////// /** - * This is core configuration file. Use it to configure core behaviour of - * Cake. - * - * @filesource - * @author Cake Authors/Developers - * @copyright Copyright (c) 2005, Cake Authors/Developers - * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers - * @package cake - * @subpackage cake.config - * @since Cake v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ + * This is core configuration file. Use it to configure core behaviour of + * Cake. + * + * @filesource + * @author Cake Authors/Developers + * @copyright Copyright (c) 2005, Cake Authors/Developers + * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers + * @package cake + * @subpackage cake.config + * @since Cake v 0.2.9 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ /** * Set debug level here: diff --git a/config/database.php.default b/config/database.php.default index 21e66f2fb..7736d24a3 100644 --- a/config/database.php.default +++ b/config/database.php.default @@ -14,26 +14,26 @@ ////////////////////////////////////////////////////////////////////////// /** - * In this file you set up your database connection details. - * - * @filesource - * @author Cake Authors/Developers - * @copyright Copyright (c) 2005, Cake Authors/Developers - * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers - * @package cake - * @subpackage cake.config - * @since Cake v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ + * In this file you set up your database connection details. + * + * @filesource + * @author Cake Authors/Developers + * @copyright Copyright (c) 2005, Cake Authors/Developers + * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers + * @package cake + * @subpackage cake.config + * @since Cake v 0.2.9 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ /** - * Database configuration array. You can configure multiple connections. - * - * @var array $DATABASE_CONFIG - */ + * Database configuration array. You can configure multiple connections. + * + * @var array $DATABASE_CONFIG + */ $DATABASE_CONFIG = array( 'devel' => array( 'driver' => 'mysql', diff --git a/config/paths.php b/config/paths.php index 0f1d189fb..67c07b5da 100644 --- a/config/paths.php +++ b/config/paths.php @@ -14,20 +14,20 @@ ////////////////////////////////////////////////////////////////////////// /** - * In this file you set paths to different directories used by Cake. - * - * @filesource - * @author Cake Authors/Developers - * @copyright Copyright (c) 2005, Cake Authors/Developers - * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers - * @package cake - * @subpackage cake.config - * @since Cake v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ + * In this file you set paths to different directories used by Cake. + * + * @filesource + * @author Cake Authors/Developers + * @copyright Copyright (c) 2005, Cake Authors/Developers + * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers + * @package cake + * @subpackage cake.config + * @since Cake v 0.2.9 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ /** * If index.php file is used instead of an .htaccess file diff --git a/config/routes.php b/config/routes.php index 6e447cc51..4470ba581 100644 --- a/config/routes.php +++ b/config/routes.php @@ -14,23 +14,23 @@ ////////////////////////////////////////////////////////////////////////// /** - * In this file, you set up routes to your controllers and their actions. - * Routes are very important mechanism that allows you to freely connect - * different urls to chosen controllers and their actions (functions). - * - * @filesource - * @author Cake Authors/Developers - * @copyright Copyright (c) 2005, Cake Authors/Developers - * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers - * @package cake - * @subpackage cake.config - * @since Cake v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - * - */ + * In this file, you set up routes to your controllers and their actions. + * Routes are very important mechanism that allows you to freely connect + * different urls to chosen controllers and their actions (functions). + * + * @filesource + * @author Cake Authors/Developers + * @copyright Copyright (c) 2005, Cake Authors/Developers + * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers + * @package cake + * @subpackage cake.config + * @since Cake v 0.2.9 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + * + */ /** * Here, we are connecting '/' (base path) to controller called 'Pages', and diff --git a/config/routes.php.default b/config/routes.php.default index 6e447cc51..4470ba581 100644 --- a/config/routes.php.default +++ b/config/routes.php.default @@ -14,23 +14,23 @@ ////////////////////////////////////////////////////////////////////////// /** - * In this file, you set up routes to your controllers and their actions. - * Routes are very important mechanism that allows you to freely connect - * different urls to chosen controllers and their actions (functions). - * - * @filesource - * @author Cake Authors/Developers - * @copyright Copyright (c) 2005, Cake Authors/Developers - * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers - * @package cake - * @subpackage cake.config - * @since Cake v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - * - */ + * In this file, you set up routes to your controllers and their actions. + * Routes are very important mechanism that allows you to freely connect + * different urls to chosen controllers and their actions (functions). + * + * @filesource + * @author Cake Authors/Developers + * @copyright Copyright (c) 2005, Cake Authors/Developers + * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers + * @package cake + * @subpackage cake.config + * @since Cake v 0.2.9 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + * + */ /** * Here, we are connecting '/' (base path) to controller called 'Pages', and diff --git a/config/tags.php b/config/tags.php index 3d9a2465c..b580ff3c5 100644 --- a/config/tags.php +++ b/config/tags.php @@ -14,21 +14,21 @@ ////////////////////////////////////////////////////////////////////////// /** - * In this file, you can set up 'templates' for every tag generated by the tag - * generator. - * - * @filesource - * @author Cake Authors/Developers - * @copyright Copyright (c) 2005, Cake Authors/Developers - * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers - * @package cake - * @subpackage cake.config - * @since Cake v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ + * In this file, you can set up 'templates' for every tag generated by the tag + * generator. + * + * @filesource + * @author Cake Authors/Developers + * @copyright Copyright (c) 2005, Cake Authors/Developers + * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers + * @package cake + * @subpackage cake.config + * @since Cake v 0.2.9 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ /** * Tag template for a link. diff --git a/libs/bake.php b/libs/bake.php index 588897416..cc86cccd3 100644 --- a/libs/bake.php +++ b/libs/bake.php @@ -14,81 +14,84 @@ ////////////////////////////////////////////////////////////////////////// /** - * Purpose: Bake - * Creates controller, model, view files, and the required directories on demand. - * Used by scripts/add.php - * - * @filesource - * @author Cake Authors/Developers - * @copyright Copyright (c) 2005, Cake Authors/Developers - * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers - * @package cake - * @subpackage cake.libs - * @since Cake v 0.2.9 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ + * Creates controller, model, view files, and the required directories on demand. + * Used by /scripts/add.php. + * + * @filesource + * @author Cake Authors/Developers + * @copyright Copyright (c) 2005, Cake Authors/Developers + * @link https://developers.nextco.com/cake/wiki/Authors Authors/Developers + * @package cake + * @subpackage cake.libs + * @since Cake v 0.2.9 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ /** - * Enter description here... - * - */ + * Require needed libraries. + */ uses('object', 'inflector'); /** - * Enter description here... - * - * - * @package cake - * @subpackage cake.libs - * @since Cake v 0.2.9 - * - */ + * Bake class creates files in configured application directories. This is a + * base class for /scripts/add.php. + * + * @package cake + * @subpackage cake.libs + * @since Cake v 0.2.9 + */ class Bake extends Object { /** - * Enter description here... - * - * @var unknown_type - */ + * Standard input stream (php://stdin). + * + * @var resource + * @access private + */ var $stdin = null; /** - * Enter description here... - * - * @var unknown_type - */ + * Standard output stream (php://stdout). + * + * @var resource + * @access private + */ var $stdout = null; /** - * Enter description here... - * - * @var unknown_type - */ + * Standard error stream (php://stderr). + * + * @var resource + * @access private + */ var $stderr = null; /** - * Enter description here... - * - * @var unknown_type - */ + * Counts taken actions. + * + * @var integer + * @access private + */ var $actions = null; /** - * Enter description here... - * - * @var unknown_type - */ - var $dont_ask = false; + * Decides wether to overwrite existing files without asking. + * + * @var boolean + * @access private + */ + var $dontAsk = false; /** - * Enter description here... - * - * @param unknown_type $type - * @return unknown - */ + * Returns template for file generator. + * + * @param string $type + * @return string + * @access private + */ function template ($type) { switch ($type) { case 'view': return "%s"; @@ -128,11 +131,18 @@ class %sTest extends TestCase { /** - * Enter description here... - * - * @param unknown_type $type - * @param unknown_type $names - */ + * Baker's constructor method. Initialises bakery, and starts production. + * + * @param string $type + * @param array $names + * @access public + * @uses Bake::stdin Opens stream for reading. + * @uses Bake::stdout Opens stream for writing. + * @uses Bake::stderr Opens stream for writing. + * @uses Bake::newModel() Depending on the case, can create a new model. + * @uses Bake::newView() Depending on the case, can create a new view. + * @uses Bake::newController() Depending on the case, can create a new controller. + */ function __construct ($type, $names) { $this->stdin = fopen('php://stdin', 'r'); @@ -177,11 +187,18 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $controller - * @param unknown_type $name - */ + * Creates new view in VIEWS/$controller/ directory. + * + * @param string $controller + * @param string $name + * @access private + * @uses Inflector::underscore() Underscores directory' name. + * @uses Bake::createDir() Creates new directory in views, depending on the controller's name. + * @uses VIEWS + * @uses Bake::createFile() Creates view file. + * @uses Bake::template() Collects view template. + * @uses Bake::actions Adds one action for each run. + */ function newView ($controller, $name) { $dir = Inflector::underscore($controller); $path = "{$dir}/".strtolower($name).".thtml"; @@ -192,11 +209,18 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $name - * @param array $actions - */ + * Creates new controller with defined actions, controller's test and helper + * with helper's test. + * + * @param string $name + * @param array $actions + * @access private + * @uses Bake::makeController() + * @uses Bake::makeControllerTest() + * @uses Bake::makeHelper() + * @uses Bake::makeHelperTest() + * @uses Bake::actions Adds one action for each run. + */ function newController ($name, $actions=array()) { $this->makeController($name, $actions); $this->makeControllerTest($name); @@ -206,12 +230,19 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $name - * @param array $actions - * @return unknown - */ + * Creates new controller file with defined actions. + * + * @param string $name + * @param array $actions + * @return boolean + * @access private + * @uses Bake::makeControllerName() CamelCase for controller's name. + * @uses Bake::makeHelperName() CamelCase for helper's name. + * @uses Bake::template() Controller's template. + * @uses Bake::getActions() Actions' templates to be included in the controller. + * @uses Bake::createFile() Creates controller's file. + * @uses Bake::makeControllerFn() Underscored name for controller's filename. + */ function makeController ($name, $actions) { $ctrl = $this->makeControllerName($name); $helper = $this->makeHelperName($name); @@ -220,31 +251,41 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Returns controller's name in CamelCase. + * + * @param string $name + * @return string + * @access private + * @uses Inflector::camelize CamelCase for controller name. + */ function makeControllerName ($name) { return Inflector::camelize($name).'Controller'; } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Returns a name for controller's file, underscored. + * + * @param string $name + * @return string + * @access private + * @uses Inflector::underscore() Underscore for controller's file name. + */ function makeControllerFn ($name) { return CONTROLLERS.Inflector::underscore($name).'_controller.php'; } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Creates new test for a controller. + * + * @param string $name + * @return boolean + * @access private + * @uses CONTROLLER_TESTS + * @uses Inflector::underscore() + * @uses Bake::getTestBody() + * @uses Bake::makeControllerName() + * @uses Bake::createFile() + */ function makeControllerTest ($name) { $fn = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php'; $body = $this->getTestBody($this->makeControllerName($name)); @@ -252,42 +293,58 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Creates new helper. + * + * @param string $name + * @return boolean + * @access private + * @uses Bake::template() + * @uses Bake::makeHelperName() + * @uses Bake::createFile() + * @uses Bake::makeHelperFn() + */ function makeHelper ($name) { $body = sprintf($this->template('helper'), $this->makeHelperName($name)); return $this->createFile($this->makeHelperFn($name), $body); } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Returns CamelCase name for a helper. + * + * @param string $name + * @return string + * @access private + * @uses Inflector::camelize() + */ function makeHelperName ($name) { return Inflector::camelize($name).'Helper'; } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Underscores file name for a helper. + * + * @param string $name + * @return string + * @access private + * @uses HELPERS + * @uses Inflector::underscore() + */ function makeHelperFn ($name) { return HELPERS.Inflector::underscore($name).'_helper.php'; } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Creates new test for a helper. + * + * @param string $name + * @return boolean + * @access private + * @uses HELPER_TESTS + * @uses Inflector::underscore() + * @uses Bake::getTestBody() + * @uses Bake::makeHelperName() + * @uses Bake::createFile() + */ function makeHelperTest ($name) { $fn = HELPER_TESTS.Inflector::underscore($name).'_helper_test.php'; $body = $this->getTestBody($this->makeHelperName($name)); @@ -295,11 +352,13 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $as - * @return unknown - */ + * Returns array of actions' templates. + * + * @param array $as + * @return array + * @access private + * @uses Bake::template() + */ function getActions ($as) { $out = array(); foreach ($as as $a) @@ -308,20 +367,29 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $class - * @return unknown - */ + * Returns test template for defined class. + * + * @param string $class + * @return string + * @access private + * @uses Bake::template() + */ function getTestBody ($class) { return sprintf($this->template('test'), $class, $class); } /** - * Enter description here... - * - * @param unknown_type $name - */ + * Creates new model. + * + * @param string $name + * @access private + * @uses Bake::createFile() + * @uses Bake::getModelFn() + * @uses Bake::template() + * @uses Bake::getModelName() + * @uses Bake::makeModelTest() + * @uses Bake::actions + */ function newModel ($name) { $this->createFile($this->getModelFn($name), sprintf($this->template('model'), $this->getModelName($name))); $this->makeModelTest ($name); @@ -329,21 +397,30 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Returns underscored name for model's file. + * + * @param string $name + * @return string + * @access private + * @uses MODELS + * @uses Inflector::underscore() + */ function getModelFn ($name) { return MODELS.Inflector::underscore($name).'.php'; } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Creates a test for a given model. + * + * @param string $name + * @return boolean + * @access private + * @uses MODEL_TESTS + * @uses Inflector::underscore() + * @uses Bake::getTestBody() + * @uses Bake::getModelName() + * @uses Bake::createFile() + */ function makeModelTest ($name) { $fn = MODEL_TESTS.Inflector::underscore($name).'_test.php'; $body = $this->getTestBody($this->getModelName($name)); @@ -351,25 +428,32 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $name - * @return unknown - */ + * Returns CamelCased name of a model. + * + * @param string $name + * @return string + * @access private + * @uses Inflector::camelize() + */ function getModelName ($name) { return Inflector::camelize($name); } /** - * Enter description here... - * - * @param unknown_type $path - * @param unknown_type $contents - * @return unknown - */ + * Creates a file with given path and contents. + * + * @param string $path + * @param string $contents + * @return boolean + * @access private + * @uses Bake::dontAsk + * @uses Bake::stdin + * @uses Bake::stdout + * @uses Bake::stderr + */ function createFile ($path, $contents) { - if (is_file($path) && !$this->dont_ask) { + if (is_file($path) && !$this->dontAsk) { fwrite($this->stdout, "File {$path} exists, overwrite? (yNaq) "); $key = fgets($this->stdin); @@ -378,7 +462,7 @@ class %sTest extends TestCase { exit; } elseif (preg_match("/^a$/", $key)) { - $this->dont_ask = true; + $this->dontAsk = true; } elseif (preg_match("/^y$/", $key)) { } @@ -403,11 +487,14 @@ class %sTest extends TestCase { } /** - * Enter description here... - * - * @param unknown_type $path - * @return unknown - */ + * Creates a directory with given path. + * + * @param string $path + * @return boolean + * @access private + * @uses Bake::stdin + * @uses Bake::stdout + */ function createDir ($path) { if (is_dir($path)) return true; @@ -426,4 +513,4 @@ class %sTest extends TestCase { } -?> \ No newline at end of file +?>