Ticket #210: phing-phpdocext-rework-php.diff
| File phing-phpdocext-rework-php.diff, 13.5 KB (added by Markus Fischer <markus@…>, 4 years ago) |
|---|
-
classes/phing/tasks/ext/phpdoc/PhpDocumentorTask.php
36 36 /** 37 37 * @var string Title for browser window / package index. 38 38 */ 39 pr ivate$title;39 protected $title; 40 40 41 41 /** 42 42 * @var PhingFile The target directory for output files. 43 43 */ 44 pr ivate$destdir;44 protected $destdir; 45 45 46 46 /** 47 47 * @var array FileSet[] Filesets for files to parse. 48 48 */ 49 pr ivate$filesets = array();49 protected $filesets = array(); 50 50 51 51 /** 52 52 * @var array FileSet[] Project documentation (README/INSTALL/CHANGELOG) files. 53 53 */ 54 pr ivate$projDocFilesets = array();54 protected $projDocFilesets = array(); 55 55 56 56 /** 57 57 * @var string Package output format. 58 58 */ 59 pr ivate$output;59 protected $output; 60 60 61 61 /** 62 62 * @var boolean Whether to generate sourcecode for each file parsed. 63 63 */ 64 pr ivate$linksource = false;64 protected $linksource = false; 65 65 66 66 /** 67 67 * @var boolean Whether to parse private members. 68 68 */ 69 pr ivate$parsePrivate = false;69 protected $parsePrivate = false; 70 70 71 71 /** 72 72 * @var boolean Whether to use javadoc descriptions (more primitive). 73 73 */ 74 pr ivate$javadocDesc = false;74 protected $javadocDesc = false; 75 75 76 76 /** 77 77 * @var PhingFile Base directory for locating template files. 78 78 */ 79 pr ivate$templateBase;79 protected $templateBase; 80 80 81 81 /** 82 82 * @var boolean Wheter to suppress output. 83 83 */ 84 pr ivate$quiet = false;84 protected $quiet = false; 85 85 86 86 /** 87 87 * @var string Comma-separated list of packages to output. 88 88 */ 89 pr ivate$packages;89 protected $packages; 90 90 91 91 /** 92 92 * @var string Comma-separated list of tags to ignore. 93 93 */ 94 pr ivate$ignoreTags;94 protected $ignoreTags; 95 95 96 96 /** 97 97 * @var string Default package name. 98 98 */ 99 pr ivate$defaultPackageName;99 protected $defaultPackageName; 100 100 101 101 /** 102 102 * @var string Default category name. 103 103 */ 104 pr ivate$defaultCategoryName;104 protected $defaultCategoryName; 105 105 106 106 /** 107 107 * @var PhingFile Directory in which to look for examples. 108 108 */ 109 pr ivate$examplesDir;109 protected $examplesDir; 110 110 111 111 /** 112 112 * @var PhingFile Directory in which to look for configuration files. 113 113 */ 114 pr ivate$configDir;114 protected $configDir; 115 115 116 116 /** 117 117 * @var boolean Whether to parse as a PEAR repository. 118 118 */ 119 private $pear = false; 119 protected $pear = false; 120 121 /** 122 * @var boolean Control whether or not warnings will be shown for 123 * undocumented elements. Useful for identifying classes and 124 * methods that haven't yet been documented. 125 */ 126 protected $undocumentedelements = false; 127 128 /** 129 * @var string custom tags, will be recognized and put in tags[] instead of 130 * unknowntags[]. 131 */ 132 protected $customtags = ''; 120 133 121 134 /** 122 135 * Set the title for the generated documentation … … 256 269 return $this->projDocFilesets[$num-1]; 257 270 } 258 271 272 /** 273 * Control whether or not warnings will be shown for undocumented elements. 274 * Useful for identifying classes and methods that haven't yet been 275 * documented. 276 * @param boolean $b 277 */ 278 public function setUndocumentedelements($b) { 279 $this->undocumentedelements = $b; 280 } 281 259 282 /** 283 * custom tags, will be recognized and put in tags[] instead of 284 * unknowntags[]. 285 * 286 * @param string $sCustomtags 287 */ 288 public function setCustomtags($sCustomtags) { 289 $this->customtags = $sCustomtags; 290 } 291 292 /** 293 * Set base location of all templates for this parse. 294 * 295 * @param PhingFile $destdir 296 */ 297 public function setTemplateBase(PhingFile $oTemplateBase) { 298 $this->templateBase = $oTemplateBase; 299 } 300 301 /** 260 302 * Searches include_path for PhpDocumentor install and adjusts include_path appropriately. 261 303 * @throws BuildException - if unable to find PhpDocumentor on include_path 262 304 */ … … 406 448 } 407 449 } 408 450 $phpdoc->setRicFiles($ricFiles); 409 451 452 if ($this->undocumentedelements) { 453 $phpdoc->setUndocumentedelements($this->undocumentedelements); 454 } 455 456 if ($this->customtags) { 457 $phpdoc->setCustomtags($this->customtags); 458 } 410 459 } 411 412 460 } -
classes/phing/tasks/ext/phpdoc/PhpDocumentorExternalTask.php
20 20 * <http://phing.info>. 21 21 */ 22 22 23 require_once 'phing/ Task.php';23 require_once 'phing/tasks/ext/phpdoc/PhpDocumentorTask.php'; 24 24 25 25 /** 26 * Task to run phpDocumentor .26 * Task to run phpDocumentor with an external process 27 27 * 28 28 * This classes uses the commandline phpdoc script to build documentation. 29 * Use this task instead of the PhpDocumentorTask when you've a clash with the 30 * Smarty libraries. 29 31 * 30 32 * @author Michiel Rook <michiel.rook@gmail.com> 33 * @author Markus Fischer <markus@fischer.name> 31 34 * @version $Id$ 32 35 * @package phing.tasks.ext.phpdoc 33 * @deprecated This task is being replaced by the new PhpDocumentorTask34 36 */ 35 class PhpDocumentorExternalTask extends Task37 class PhpDocumentorExternalTask extends PhpDocumentorTask 36 38 { 37 39 /** 38 40 * The path to the executable for phpDocumentor 39 41 */ 40 pr ivate$programPath = 'phpdoc';42 protected $programPath = 'phpdoc'; 41 43 42 pr ivate $title = "Default Title";44 protected $sourcepath = NULL; 43 45 44 private $destdir = "."; 46 /** 47 * @var bool ignore symlinks to other files or directories 48 */ 49 protected $ignoresymlinks = false; 45 50 46 private $sourcepath = NULL;47 48 private $output = "";49 50 private $linksource = false;51 52 private $parseprivate = false;53 54 51 /** 55 52 * Sets the path to the phpDocumentor executable 56 53 */ 57 function setProgramPath($programPath)54 public function setProgramPath($programPath) 58 55 { 59 56 $this->programPath = $programPath; 60 57 } … … 62 59 /** 63 60 * Returns the path to the phpDocumentor executable 64 61 */ 65 function getProgramPath()62 public function getProgramPath() 66 63 { 67 64 return $this->programPath; 68 65 } 69 66 70 67 /** 71 * Set the title for the generated documentation 68 * Set the source path. A directory or a comma separate list of directories. 72 69 */ 73 function setTitle($title)70 public function setSourcepath($sourcepath) 74 71 { 75 $this->title = $title;72 $this->sourcepath = $sourcepath; 76 73 } 77 74 78 /** 79 * Set the destination directory for the generated documentation 80 */ 81 function setDestdir($destdir) 82 { 83 $this->destdir = $destdir; 84 } 75 /** 76 * Ignore symlinks to other files or directories. 77 * 78 * @param bool $bSet 79 */ 80 public function setIgnoresymlinks($bSet) { 81 $this->ignoresymlinks = $bSet; 82 } 85 83 86 84 /** 87 * Set the source path88 */89 function setSourcepath(Path $sourcepath)90 {91 if ($this->sourcepath === NULL)92 {93 $this->sourcepath = $sourcepath;94 }95 else96 {97 $this->sourcepath->append($sourcepath);98 }99 }100 101 /**102 * Set the output type103 */104 function setOutput($output)105 {106 $this->output = $output;107 }108 109 /**110 * Should sources be linked in the generated documentation111 */112 function setLinksource($linksource)113 {114 $this->linksource = $linksource;115 }116 117 /**118 * Should private members/classes be documented119 */120 function setParseprivate($parseprivate)121 {122 $this->parseprivate = $parseprivate;123 }124 125 /**126 85 * Main entrypoint of the task 127 86 */ 128 function main()87 public function main() 129 88 { 130 $arguments = $this->constructArguments(); 89 $this->validate(); 90 $arguments = join(' ', $this->constructArguments()); 131 91 132 92 $this->log("Running phpDocumentor..."); 133 93 … … 152 112 153 113 /** 154 114 * Constructs an argument string for phpDocumentor 115 * @return array 155 116 */ 156 pr ivatefunction constructArguments()117 protected function constructArguments() 157 118 { 158 $arguments = "-q on "; 159 119 $aArgs = array(); 160 120 if ($this->title) 161 121 { 162 $a rguments.= "-ti \"" . $this->title . "\" ";122 $aArgs[] = '--title "' . $this->title . '"'; 163 123 } 164 124 165 125 if ($this->destdir) 166 126 { 167 $a rguments.= "-t \"" . $this->destdir . "\" ";127 $aArgs[] = '--target "' . $this->destdir->getAbsolutePath() . '"'; 168 128 } 169 129 170 if ($this->sourcepath !== NULL)130 if ($this->sourcepath) 171 131 { 172 $a rguments.= "-d \"" . $this->sourcepath->__toString() . "\" ";132 $aArgs[] = '--directory "' . $this->sourcepath . '"'; 173 133 } 174 134 175 135 if ($this->output) 176 136 { 177 $a rguments.= "-o " . $this->output . " ";137 $aArgs[] = '--output ' . $this->output; 178 138 } 179 139 180 140 if ($this->linksource) 181 141 { 182 $a rguments.= "-s on ";142 $aArgs[] = '--sourcecode on'; 183 143 } 184 144 185 145 if ($this->parseprivate) 186 146 { 187 $a rguments.= "-pp on ";147 $aArgs[] = '--parseprivate on'; 188 148 } 189 149 190 return $arguments; 150 // append any files in filesets 151 $filesToParse = array(); 152 foreach($this->filesets as $fs) { 153 $files = $fs->getDirectoryScanner($this->project)->getIncludedFiles(); 154 foreach($files as $filename) { 155 $f = new PhingFile($fs->getDir($this->project), $filename); 156 $filesToParse[] = $f->getAbsolutePath(); 157 } 158 } 159 if (count($filesToParse) > 0) { 160 $aArgs[] = '--filename "' . join(',', $filesToParse) . '"'; 161 } 162 163 // append any files in filesets 164 $ricFiles = array(); 165 foreach($this->projDocFilesets as $fs) { 166 $files = $fs->getDirectoryScanner($this->project)->getIncludedFiles(); 167 foreach($files as $filename) { 168 $f = new PhingFile($fs->getDir($this->project), $filename); 169 $ricFiles[] = $f->getAbsolutePath(); 170 } 171 } 172 if (count($ricFiles) > 0) { 173 $aArgs[] = '--readmeinstallchangelog "' . 174 join(',', $ricFiles) . '"'; 175 } 176 177 if ($this->javadocDesc) { 178 $aArgs[] = '--javadocdesc on'; 179 } 180 181 if ($this->quiet) { 182 $aArgs[] = '--quiet on'; 183 } 184 185 if ($this->packages) { 186 $aArgs[] = '--packageoutput "' . $this->packages . '"'; 187 } 188 189 if ($this->ignoreTags) { 190 $aArgs[] = '--ignore-tags "' . $this->ignoreTags . '"'; 191 } 192 193 if ($this->defaultCategoryName) { 194 $aArgs[] = '--defaultcategoryname "' . $this->defaultCategoryName . 195 '"'; 196 } 197 198 if ($this->examplesDir) { 199 $aArgs[] = '--examplesdir "' . $this->examplesDir->getAbsolutePath() 200 . '"'; 201 } 202 203 if ($this->templateBase) { 204 $aArgs[] = '--templatebase "' . $this->templateBase->getAbsolutePath() 205 . '"'; 206 } 207 208 if ($this->pear) { 209 $aArgs[] = '--pear on'; 210 } 211 212 if ($this->undocumentedelements) { 213 $aArgs[] = '--undocumentedelements on'; 214 } 215 216 if ($this->customtags) { 217 $aArgs[] = '--customtags "' . $this->customtags . '"'; 218 } 219 220 if ($this->ignoresymlinks) { 221 $aArgs[] = '--ignoresymlinks on'; 222 } 223 224 var_dump($aArgs);exit; 225 return $aArgs; 191 226 } 227 228 /** 229 * Override PhpDocumentorTask::init() because they're specific to the phpdoc 230 * API which we don't use. 231 */ 232 public function init() { 233 } 234 235 /** 236 * Validates that necessary minimum options have been set. Based on 237 * PhpDocumentorTask::validate(). 238 */ 239 protected function validate() { 240 if (!$this->destdir) { 241 throw new BuildException("You must specify a destdir for phpdoc.", 242 $this->getLocation()); 243 } 244 if (!$this->output) { 245 throw new BuildException("You must specify an output format for " . 246 "phpdoc (e.g. HTML:frames:default).", $this->getLocation()); 247 } 248 if (empty($this->filesets) && !$this->sourcepath) { 249 throw new BuildException("You have not specified any files to " . 250 "include (<fileset> or sourcepath attribute) for phpdoc.", 251 $this->getLocation()); 252 } 253 if ($this->configdir) { 254 $this->log('Ignoring unsupported configdir-Attribute', 255 Project::MSG_VERBOSE); 256 } 257 } 192 258 }; 193 259 194 260 -
classes/phing/tasks/ext/phpdoc/PhingPhpDocumentorSetup.php
172 172 $_phpDocumentor_setting['quiet'] = true; 173 173 parent::setQuietMode(); 174 174 } 175 176 } 177 No newline at end of file 175 176 /** 177 * Control whether or not warnings will be shown for undocumented elements. 178 * Useful for identifying classes and methods that haven't yet been 179 * documented. 180 * 181 * @param bool $bEnable 182 */ 183 public function setUndocumentedelements($bEnable) { 184 $this->render->setUndocumentedElementWarningsMode($bEnable); 185 } 186 187 /** 188 * custom tags, will be recognized and put in tags[] instead of 189 * unknowntags[] 190 * 191 * This method exists as a hack because the API exposed for this method in 192 * PhpDocumentor doesn't work correctly. 193 * 194 * Note that because we are setting a "private" GLOBAL(!!) config var with 195 * this value, this is subject to break if PhpDocumentor internals changes. 196 * 197 * @param string $sCustomtags 198 */ 199 public function setCustomtags($sCustomtags) { 200 global $_phpDocumentor_setting; 201 $_phpDocumentor_setting['customtags'] = $sCustomtags; 202 } 203 }
