pearweb_manual
[ class tree: pearweb_manual ] [ index: pearweb_manual ] [ all elements ]

Source for file apidoc-queue.php

Documentation is available at apidoc-queue.php

  1. #!/usr/local/bin/php
  2. <?php
  3. /*
  4.  * +----------------------------------------------------------------------+
  5.  * | PEAR Web site version 1.0                                            |
  6.  * +----------------------------------------------------------------------+
  7.  * | Copyright (c) 2004-2005 The PEAR Group                               |
  8.  * +----------------------------------------------------------------------+
  9.  * | This source file is subject to version 2.02 of the PHP license,      |
  10.  * | that is bundled with this package in the file LICENSE, and is        |
  11.  * | available at through the world-wide-web at                           |
  12.  * | http://www.php.net/license/2_02.txt.                                 |
  13.  * | If you did not receive a copy of the PHP license and are unable to   |
  14.  * | obtain it through the world-wide-web, please send a note to          |
  15.  * | license@php.net so we can mail you a copy immediately.               |
  16.  * +----------------------------------------------------------------------+
  17.  * | Author: Martin Jansen <mj@php.net>                                   |
  18.  * +----------------------------------------------------------------------+
  19.  *
  20.  * $Id$
  21.  */
  22. // Old PHPDocumentor setup:
  23. // For manual testing on sg1
  24. // $_ENV['PEAR_DATABASE_DSN'] = 'mysqli://user:password@localhost/database';
  25.  
  26. // 1. Ensure you have the appropriate phpdocumentor html template smarty bit installed.
  27. // ERROR: template directory "/usr/local/lib/php/pear/data/PhpDocumentor/phpDocumentor/Converters/HTML/Smarty/templates/PEAR/" does not exist
  28. // svn co svn co https://svn.php.net/repository/pear/packages/PhpDocumentor/trunk/ ../PhpDocumentor
  29. //  cp -R ../PhpDocumentor/phpDocumentor/Converters/HTML/Smarty/templates/PEAR/* /usr/local/lib/php/pear/data/PhpDocumentor/phpDocumentor/Converters/HTML/Smarty/templates/PEAR/
  30.  
  31. // 2. Ensure you have a package in the correct APIDOC_QUEUE location - IE
  32. // /home/pear/packages/Validate_HU-0.1.2.tgz
  33. // 3. Ensure the apidoc_queue table has an entry to that .tar.gz file. IE:
  34. // INSERT INTO  apidoc_queue(filename) VALUES( '/home/pear/packages/Validate_HU-0.1.2.tgz');
  35.  
  36. // Shiny new docblox setup
  37. // pear channel-discover pear.docblox-project.org
  38. // pear channel-discover pear.michelf.com
  39. // pear install michelf/markdownextra
  40. // pear install docblox
  41. // apt-get install graphviz
  42. // And... uncomment the below
  43.  
  44.  
  45. require_once dirname(dirname(__FILE__)) '/include/pear-config.php';
  46. require_once 'DB.php';
  47. require_once 'PEAR/Common.php';
  48. require_once 'Archive/Tar.php';
  49.  
  50. $debug = false;
  51.  
  52. class apidocqueue extends PEAR_Common
  53. {
  54.     // {{{ infoFromTgzFile()
  55.     /**
  56.      * Returns information about a package file.  Expects the name of
  57.      * a gzipped tar file as input.
  58.      *
  59.      * @param string  $file  name of .tgz file
  60.      *
  61.      * @return array  array with package information
  62.      *
  63.      * @access public
  64.      * @deprecated use PEAR_PackageFile->fromTgzFile() instead
  65.      *
  66.      */
  67.     function infoFromTgzFile($file)
  68.     {
  69.         $config &PEAR_Config::singleton();
  70.         $packagefile = new PEAR_PackageFile($config);
  71.         $pf &$packagefile->fromTgzFile($filePEAR_VALIDATE_NORMAL);
  72.         if (PEAR::isError($pf)) {
  73.             $errs $pf->getUserinfo();
  74.             if (is_array($errs)) {
  75.                 foreach ($errs as $error{
  76.                     $e $this->raiseError($error['message']$error['code']nullnull$error);
  77.                 }
  78.             }
  79.             return $pf;
  80.         }
  81.         return $this->_postProcessValidPackagexml($pf);
  82.     }
  83.  
  84.    /**
  85.      * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  86.      * @return array 
  87.      */
  88.     function _postProcessValidPackagexml(&$pf)
  89.     {
  90.         if (is_a($pf'PEAR_PackageFile_v2')) {
  91.             // sort of make this into a package.xml 1.0-style array
  92.             // changelog is not converted to old format.
  93.             $arr $pf->toArray(true);
  94.             $arr array_merge($arr$arr['old']);
  95.             unset($arr['old']);
  96.             unset($arr['xsdversion']);
  97.             unset($arr['contents']);
  98.             unset($arr['compatible']);
  99.             unset($arr['channel']);
  100.             unset($arr['uri']);
  101.             unset($arr['dependencies']);
  102.             unset($arr['phprelease']);
  103.             unset($arr['extsrcrelease']);
  104.             unset($arr['zendextsrcrelease']);
  105.             unset($arr['extbinrelease']);
  106.             unset($arr['zendextbinrelease']);
  107.             unset($arr['bundle']);
  108.             unset($arr['lead']);
  109.             unset($arr['developer']);
  110.             unset($arr['helper']);
  111.             unset($arr['contributor']);
  112.             $arr['filelist'$pf->getFilelist();
  113.             $this->pkginfo $arr;
  114.             return $arr;
  115.         else {
  116.             $this->pkginfo $pf->toArray();
  117.             return $this->pkginfo;
  118.         }
  119.     }
  120. }
  121.  
  122. $pkg_handler = new apidocqueue();
  123.  
  124. $options = array(
  125.     'persistent' => false,
  126.     'portability' => DB_PORTABILITY_ALL,
  127. );
  128. $dbh = DB::connect(PEAR_DATABASE_DSN$options);
  129. if (PEAR::isError($dbh)) {
  130.     die($dbh->getMessage());
  131. }
  132. $query "SELECT filename FROM apidoc_queue WHERE finished = '0000-00-00 00:00:00'";
  133. $rows $dbh->getCol($query);
  134.  
  135. foreach ($rows as $filename{
  136.     $info $pkg_handler->infoFromTgzFile($filename);
  137.     $tar = new Archive_Tar($filename);
  138.  
  139.     if (PEAR::isError($info)) {
  140.         trigger_error($info->getMessage());
  141.         continue;
  142.     }
  143.  
  144.     $name (isset($info['package']$info['package'$info['name']);
  145.  
  146.     echo "Generating documentation for " $name " " $info['version'"\n";
  147.  
  148.     /* Extract files into temporary directory */
  149.     $tmpdir = PEAR_TMPDIR . "/apidoc/" $name;
  150.  
  151.     if (!$pkg_handler->mkDirHier($tmpdir)) {
  152.         die("Unable to create temporary directory " $tmpdir "\n");
  153.     }
  154.  
  155.     $tar->extract($tmpdir);
  156.  
  157.  
  158.     switch (PEAR_DOCUMENTATION_ENGINE{
  159.         case 'phpdocumentor2':
  160.             $command sprintf(
  161.                 "/usr/local/bin/phpdoc -d %s --title '%s' -t %s --ignore */data/*,*/tests/*; rm -rf %s",
  162.                 $tmpdir,
  163.                 $name " " $info['version'],
  164.                 PEAR_APIDOC_DIR . "/" $name "-" $info['version'],
  165.                 $tmpdir
  166.             );
  167.  
  168.             break;
  169.         case 'phpdocumentor':
  170.         default:
  171.             $command sprintf(
  172.                 "/usr/local/bin/phpdoc -d %s -dn '%s' -ti '%s' -p on -s on -t %s -o %s --ignore */data/*,*/tests/*; rm -rf %s",
  173.                 $tmpdir,
  174.                 $name,
  175.                 $name " " $info['version'],
  176.                 PEAR_APIDOC_DIR . "/" $name "-" $info['version'],
  177.                 "HTML:Smarty:PEAR",
  178.                 $tmpdir
  179.             );
  180.  
  181.             break;
  182.     }
  183.  
  184.     $output "";
  185.     $process popen($command"r");
  186.  
  187.     if ($process{
  188.         while ($line fgets($process)) {
  189.             $output .= $line;
  190.         }
  191.         pclose($process);
  192.  
  193.         //update "latest" symlink
  194.         $latestdir  = PEAR_APIDOC_DIR . $name '-latest';
  195.         $versiondir = PEAR_APIDOC_DIR . $name '-' $info['version'];
  196.         is_link($latestdir&& unlink($latestdir);
  197.         symlink($versiondir$latestdir);
  198.  
  199.         // In debug mode; we render the output to stdout
  200.         if ($debug{
  201.             print $output;
  202.         }
  203.  
  204.         // In debug mode; we may not wish to write back changes
  205.         if (!$debug{
  206.             $query "UPDATE apidoc_queue SET finished = NOW(), log = ? WHERE filename = ?";
  207.             $dbh->query($queryarray($output$filename));
  208.         
  209.     }
  210. }

Documentation generated on Mon, 11 Mar 2019 16:04:25 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.