home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / phing / tasks / ext / phpdoc / PhpDocumentorExternalTask.php < prev    next >
Encoding:
PHP Script  |  2007-02-15  |  4.0 KB  |  195 lines

  1. <?php
  2.  
  3. /**
  4.  * $Id: PhpDocumentorExternalTask.php 155 2007-02-15 14:24:35Z hans $
  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.  * This classes uses the commandline phpdoc script to build documentation.
  29.  *
  30.  * @author Michiel Rook <michiel.rook@gmail.com>
  31.  * @version $Id: PhpDocumentorExternalTask.php 155 2007-02-15 14:24:35Z hans $
  32.  * @package phing.tasks.ext.phpdoc
  33.  * @deprecated This task is being replaced by the new PhpDocumentorTask
  34.  */    
  35. class PhpDocumentorExternalTask extends Task
  36. {
  37.     /**
  38.      * The path to the executable for phpDocumentor
  39.      */
  40.     private $programPath = 'phpdoc';
  41.  
  42.     private $title = "Default Title";
  43.  
  44.     private $destdir = ".";
  45.  
  46.     private $sourcepath = NULL;
  47.  
  48.     private $output = "";
  49.  
  50.     private $linksource = false;
  51.  
  52.     private $parseprivate = false;
  53.  
  54.     /**
  55.      * Sets the path to the phpDocumentor executable
  56.      */
  57.     function setProgramPath($programPath)
  58.     {
  59.         $this->programPath = $programPath;
  60.     }
  61.  
  62.     /**
  63.      * Returns the path to the phpDocumentor executable
  64.      */
  65.     function getProgramPath()
  66.     {
  67.         return $this->programPath;
  68.     }
  69.  
  70.     /**
  71.      * Set the title for the generated documentation
  72.      */
  73.     function setTitle($title)
  74.     {
  75.         $this->title = $title;
  76.     }
  77.  
  78.     /**
  79.      * Set the destination directory for the generated documentation
  80.      */
  81.     function setDestdir($destdir)
  82.     {
  83.         $this->destdir = $destdir;
  84.     }
  85.  
  86.     /**
  87.      * Set the source path
  88.      */
  89.     function setSourcepath(Path $sourcepath)
  90.     {
  91.         if ($this->sourcepath === NULL)
  92.         {
  93.             $this->sourcepath = $sourcepath;
  94.         }
  95.         else
  96.         {
  97.             $this->sourcepath->append($sourcepath);
  98.         }
  99.     }
  100.  
  101.     /**
  102.      * Set the output type
  103.      */        
  104.     function setOutput($output)
  105.     {
  106.         $this->output = $output;
  107.     }
  108.  
  109.     /**
  110.      * Should sources be linked in the generated documentation
  111.      */
  112.     function setLinksource($linksource)
  113.     {
  114.         $this->linksource = $linksource;
  115.     }
  116.  
  117.     /**
  118.      * Should private members/classes be documented
  119.      */
  120.     function setParseprivate($parseprivate)
  121.     {
  122.         $this->parseprivate = $parseprivate;
  123.     }
  124.  
  125.     /**
  126.      * Main entrypoint of the task
  127.      */
  128.     function main()
  129.     {
  130.         $arguments = $this->constructArguments();
  131.  
  132.         $this->log("Running phpDocumentor...");
  133.  
  134.         exec($this->programPath . " " . $arguments, $output, $return);
  135.  
  136.         if ($return != 0)
  137.         {
  138.             throw new BuildException("Could not execute phpDocumentor: " . implode(' ', $output));
  139.         }
  140.         
  141.         foreach($output as $line)
  142.         {
  143.             if(strpos($line, 'ERROR') !== false)
  144.             {
  145.                 $this->log($line, Project::MSG_ERR);
  146.                 continue;
  147.             }
  148.             
  149.             $this->log($line, Project::MSG_VERBOSE);
  150.         }
  151.     }
  152.  
  153.     /**
  154.      * Constructs an argument string for phpDocumentor
  155.      */
  156.     private function constructArguments()
  157.     {
  158.         $arguments = "-q on ";
  159.  
  160.         if ($this->title)
  161.         {
  162.             $arguments.= "-ti \"" . $this->title . "\" ";
  163.         }
  164.  
  165.         if ($this->destdir)
  166.         {
  167.             $arguments.= "-t \"" . $this->destdir . "\" ";
  168.         }
  169.  
  170.         if ($this->sourcepath !== NULL)
  171.         {
  172.             $arguments.= "-d \"" . $this->sourcepath->__toString() . "\" ";
  173.         }
  174.  
  175.         if ($this->output)
  176.         {
  177.             $arguments.= "-o " . $this->output . " ";
  178.         }
  179.  
  180.         if ($this->linksource)
  181.         {
  182.             $arguments.= "-s on ";
  183.         }
  184.  
  185.         if ($this->parseprivate)
  186.         {
  187.             $arguments.= "-pp on ";
  188.         }
  189.  
  190.         return $arguments;
  191.     }
  192. };
  193.  
  194. ?>
  195.