Changeset 65

Show
Ignore:
Timestamp:
05/04/06 12:12:43 (2 years ago)
Author:
mrook
Message:

Change indentation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.2/classes/phing/tasks/ext/phpdoc/PHPDocumentorTask.php

    r61 r65  
    11<?php 
    22 
     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 
     23require_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 */      
     32class PHPDocumentorTask extends Task 
     33{ 
    334        /** 
    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 
    2136         */ 
    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; 
    2450 
    2551        /** 
    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) 
    3355        { 
    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        } 
    5058 
    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) 
    5573                { 
    56                         $this->title = $title
     74                        $this->sourcepath = $sourcepath
    5775                } 
    58                  
    59                 /** 
    60                  * Set the destination directory for the generated documentation 
    61                  */ 
    62                 function setDestdir($destdir) 
     76                else 
    6377                { 
    64                         $this->destdir = $destdir
     78                        $this->sourcepath->append($sourcepath)
    6579                } 
    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) 
    71118                { 
    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)); 
    80120                } 
    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) 
    86131                { 
    87                         $this->output = $output
     132                        $arguments.= "-ti \"" . $this->title . "\" "
    88133                } 
    89                  
    90                 /** 
    91                  * Should sources be linked in the generated documentation 
    92                  */ 
    93                 function setLinksource($linksource) 
     134 
     135                if ($this->destdir) 
    94136                { 
    95                         $this->linksource = $linksource
     137                        $arguments.= "-t " . $this->destdir . " "
    96138                } 
    97                  
    98                 /** 
    99                  * Should private members/classes be documented 
    100                  */ 
    101                 function setParseprivate($parseprivate) 
     139 
     140                if ($this->sourcepath !== NULL) 
    102141                { 
    103                         $this->parseprivate = $parseprivate
     142                        $arguments.= "-d " . $this->sourcepath->__toString() . " "
    104143                } 
    105                  
    106                 /** 
    107                  * Main entrypoint of the task 
    108                  */ 
    109                 function main() 
     144 
     145                if ($this->output) 
    110146                { 
    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 . " "; 
    121148                } 
    122                  
    123                 /** 
    124                  * Constructs an argument string for phpDocumentor 
    125                  */ 
    126                 private function constructArguments() 
     149 
     150                if ($this->linksource) 
    127151                { 
    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 "; 
    161153                } 
    162         }; 
     154 
     155                if ($this->parseprivate) 
     156                { 
     157                        $arguments.= "-pp "; 
     158                } 
     159 
     160                return $arguments; 
     161        } 
     162}; 
    163163 
    164164?>