Changeset 65
- Timestamp:
- 05/04/06 12:12:43 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2.2/classes/phing/tasks/ext/phpdoc/PHPDocumentorTask.php
r61 r65 1 1 <?php 2 2 3 /** 4 * $Id$ 5 * 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 7 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 8 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 9 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 10 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 11 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 12 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 13 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 14 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 16 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 * 18 * This software consists of voluntary contributions made by many individuals 19 * and is licensed under the LGPL. For more information please see 20 * <http://phing.info>. 21 */ 22 23 require_once 'phing/Task.php'; 24 25 /** 26 * Task to run phpDocumentor. 27 * 28 * @author Michiel Rook <michiel@trendserver.nl> 29 * @version $Id$ 30 * @package phing.tasks.ext.phpdoc 31 */ 32 class PHPDocumentorTask extends Task 33 { 3 34 /** 4 * $Id$ 5 * 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 7 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 8 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 9 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 10 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 11 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 12 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 13 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 14 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 16 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 * 18 * This software consists of voluntary contributions made by many individuals 19 * and is licensed under the LGPL. For more information please see 20 * <http://phing.info>. 35 * The name of the executable for phpDocumentor 21 36 */ 22 23 require_once 'phing/Task.php'; 37 const PHPDOC = 'phpdoc'; 38 39 private $title = "Default Title"; 40 41 private $destdir = "."; 42 43 private $sourcepath = NULL; 44 45 private $output = ""; 46 47 private $linksource = false; 48 49 private $parseprivate = false; 24 50 25 51 /** 26 * Task to run phpDocumentor. 27 * 28 * @author Michiel Rook <michiel@trendserver.nl> 29 * @version $Id$ 30 * @package phing.tasks.ext.phpdoc 31 */ 32 class PHPDocumentorTask extends Task 52 * Set the title for the generated documentation 53 */ 54 function setTitle($title) 33 55 { 34 /** 35 * The name of the executable for phpDocumentor 36 */ 37 const PHPDOC = 'phpdoc'; 38 39 private $title = "Default Title"; 40 41 private $destdir = "."; 42 43 private $sourcepath = NULL; 44 45 private $output = ""; 46 47 private $linksource = false; 48 49 private $parseprivate = false; 56 $this->title = $title; 57 } 50 58 51 /** 52 * Set the title for the generated documentation 53 */ 54 function setTitle($title) 59 /** 60 * Set the destination directory for the generated documentation 61 */ 62 function setDestdir($destdir) 63 { 64 $this->destdir = $destdir; 65 } 66 67 /** 68 * Set the source path 69 */ 70 function setSourcepath(Path $sourcepath) 71 { 72 if ($this->sourcepath === NULL) 55 73 { 56 $this-> title = $title;74 $this->sourcepath = $sourcepath; 57 75 } 58 59 /** 60 * Set the destination directory for the generated documentation 61 */ 62 function setDestdir($destdir) 76 else 63 77 { 64 $this-> destdir = $destdir;78 $this->sourcepath->append($sourcepath); 65 79 } 66 67 /** 68 * Set the source path 69 */ 70 function setSourcepath(Path $sourcepath) 80 } 81 82 /** 83 * Set the output type 84 */ 85 function setOutput($output) 86 { 87 $this->output = $output; 88 } 89 90 /** 91 * Should sources be linked in the generated documentation 92 */ 93 function setLinksource($linksource) 94 { 95 $this->linksource = $linksource; 96 } 97 98 /** 99 * Should private members/classes be documented 100 */ 101 function setParseprivate($parseprivate) 102 { 103 $this->parseprivate = $parseprivate; 104 } 105 106 /** 107 * Main entrypoint of the task 108 */ 109 function main() 110 { 111 $arguments = $this->constructArguments(); 112 113 $this->log("Running phpDocumentor..."); 114 115 exec(self::PHPDOC . " " . $arguments, $output, $return); 116 117 if ($return != 0) 71 118 { 72 if ($this->sourcepath === NULL) 73 { 74 $this->sourcepath = $sourcepath; 75 } 76 else 77 { 78 $this->sourcepath->append($sourcepath); 79 } 119 throw new BuildException("Could not execute ionCube Encoder: " . implode(' ', $output)); 80 120 } 81 82 /** 83 * Set the output type 84 */ 85 function setOutput($output) 121 } 122 123 /** 124 * Constructs an argument string for phpDocumentor 125 */ 126 private function constructArguments() 127 { 128 $arguments = "-q on "; 129 130 if ($this->title) 86 131 { 87 $ this->output = $output;132 $arguments.= "-ti \"" . $this->title . "\" "; 88 133 } 89 90 /** 91 * Should sources be linked in the generated documentation 92 */ 93 function setLinksource($linksource) 134 135 if ($this->destdir) 94 136 { 95 $ this->linksource = $linksource;137 $arguments.= "-t " . $this->destdir . " "; 96 138 } 97 98 /** 99 * Should private members/classes be documented 100 */ 101 function setParseprivate($parseprivate) 139 140 if ($this->sourcepath !== NULL) 102 141 { 103 $ this->parseprivate = $parseprivate;142 $arguments.= "-d " . $this->sourcepath->__toString() . " "; 104 143 } 105 106 /** 107 * Main entrypoint of the task 108 */ 109 function main() 144 145 if ($this->output) 110 146 { 111 $arguments = $this->constructArguments(); 112 113 $this->log("Running phpDocumentor..."); 114 115 exec(self::PHPDOC . " " . $arguments, $output, $return); 116 117 if ($return != 0) 118 { 119 throw new BuildException("Could not execute ionCube Encoder: " . implode(' ', $output)); 120 } 147 $arguments.= "-o " . $this->output . " "; 121 148 } 122 123 /** 124 * Constructs an argument string for phpDocumentor 125 */ 126 private function constructArguments() 149 150 if ($this->linksource) 127 151 { 128 $arguments = "-q on "; 129 130 if ($this->title) 131 { 132 $arguments.= "-ti \"" . $this->title . "\" "; 133 } 134 135 if ($this->destdir) 136 { 137 $arguments.= "-t " . $this->destdir . " "; 138 } 139 140 if ($this->sourcepath !== NULL) 141 { 142 $arguments.= "-d " . $this->sourcepath->__toString() . " "; 143 } 144 145 if ($this->output) 146 { 147 $arguments.= "-o " . $this->output . " "; 148 } 149 150 if ($this->linksource) 151 { 152 $arguments.= "-s "; 153 } 154 155 if ($this->parseprivate) 156 { 157 $arguments.= "-pp "; 158 } 159 160 return $arguments; 152 $arguments.= "-s "; 161 153 } 162 }; 154 155 if ($this->parseprivate) 156 { 157 $arguments.= "-pp "; 158 } 159 160 return $arguments; 161 } 162 }; 163 163 164 164 ?>
