コード例 #1
0
$values['author'] = 'Sofia Cardita';
$values['email'] = '*****@*****.**';
$values['license'] = '';
$values['category'] = '';
$values['link'] = '';
$values['package'] = '';
$values['see'] = '';
$values['version'] = '';
$values['year'] = '';
//END OF USER CONFIGURABLE OPTIONS///
//current file being edited
$file = getenv('CODA_FILEPATH');
$outFile = '/tmp/docblock.txt';
$path = 'PHP/DocBlockGenerator.php';
if (!file_exists($path)) {
    echo 'File not found: ' . $path . '. Pear must be in your path. If not
            you need to set the correct path to Pear\'s PHP_DocBlockGenerator. ' . 'Included paths: ' . get_include_path() . '. Change it in this file: ' . __FILE__;
    exit(1);
}
require_once $path;
// Run command line interface
$pdocblock = new PHP_DocBlockGenerator();
$pdocblock->generate($file, $values, $outFile);
$str = @file_get_contents($outFile);
$contents = ob_get_contents();
ob_end_clean();
//print just the file
//contents with the new
//docblocks
echo $str;
exit(0);
コード例 #2
0
 /**
  * This function adds doc blocks to the outputfile
  * 
  * @return void   
  * @access private
  */
 private function addDocBlocks()
 {
     $settings = $this->docBlockIniParser->getSettings();
     $docblockgen = new PHP_DocBlockGenerator();
     $docblockgen->generate($this->output_filename, $settings, $this->output_filename);
 }
コード例 #3
0
 /**
  * The command line interface for DOS/Unix command
  *
  * Primarily meant to be called by the "docblockgen" shell script.
  * Processes the DOS/Unix command options/arguments,
  * creates an instance of the class itself and starts the process.
  * The default input file is the standard input and the default ouput file
  * is the standard output.
  * Exits with 0 on success, or dies and displays an error message
  * on the CLI on failure.
  *
  * <pre>
  * Example 1: Realigns DocBlock tags
  * #docblockgen -A foo.php
  *
  * Example 2: Creates Docblocks for foo.php in docfoo.php with some specific Page tags
  * #docblockgen -la -c PHP -a "John Foo" -e '*****@*****.**' -y 1999-2007 foo.php docfoo.php
  *
  * Example 3: Displays the command usage
  * #docblockgen -h
  * This displays:
  * <pre>
  * Usage: docblockgen [options] [infile] [,outfile]
  *         docblockgen -A [infile] [,outfile]
  * Options:
  * -a --author <name>            The author's name, e.g. "John Foo".
  * -c --category <name>          The category name, e.g. PHP.
  *                                See http://pear.php.net/packages.php.
  * -e --email <*****@*****.**> The author's email address.
  * -i --infile <name>            The input PHP file to process. Default: STDIN.
  * -l --license <apache20|bsd|lgpl21|mit|php301|*>
  *                                The license. Default: bsd.
  * -o --outfile <name>           The output file. Default: infile
  *                                or STDOUT if infile is STDIN.
  * -p --package <name>           The package name.
  *                                Default: the first 2 words of the class name.
  * -u --link <http://...>        The package link.
  *                                Default: http://pear.php.net/package/name.
  * -v --version <cvs|svn|*>      The file version. Default: CVS keyword.
  * -y --year <yyyy>              The copyright year. Default: the current year.
  * -A --align                    Aligns existing DocBlock tags.
  *                                Other options are ignored.
  * -h --help                     This help.
  * Parameters:  [infile] [,outfile]
  *               The input and output files. See the -i and -o options.
  * Note: Option values requiring space separated words, for example the author's
  * name,must be enclosed with double-quotes.
  * </pre>
  *
  * @return void
  * @access public
  * @static
  * @see    scripts/gendocblock, scripts/gendocblock.bat
  */
 public static function generate()
 {
     // extracts the options and parameters
     list($options, $parameters) = PHP_DocBlockGenerator_GetoptPlus::getopt(self::$config);
     // extracts the infile and outfile as parameters, over-rides the "-i" and "-o" options
     $infile = current($parameters) and $options['infile'] = $infile;
     $outfile = next($parameters) and $options['outfile'] = $outfile;
     // captures the outfile or defaults the outfile to the infile or the standard output
     isset($options['outfile']) and $outfile = $options['outfile'] or $outfile = isset($options['infile']) ? $options['infile'] : 'php://stdout';
     // captures the infile or defaults to the standard input
     $infile = isset($options['infile']) ? $options['infile'] : 'php://stdin';
     $docblockgen = new PHP_DocBlockGenerator();
     if (!$docblockgen->generate($infile, $options, $outfile)) {
         // error when accessing the file(s)
         $infile != $outfile and $infile .= " and/or the file: {$outfile}";
         die("Error! Cannot access|read|write the file: {$infile}");
     }
     exit(0);
 }