|
<?php /** * File and input handling routines * * This class parses command-line options, and works with files to * generate lists of files to parse based on the ignore/include options * * phpDocumentor :: automatic documentation generator * * PHP versions 4 and 5 * * Copyright (c) 2000-2006 Joshua Eichorn, Gregory Beaver * * LICENSE: * * This library is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; * either version 2.1 of the License, or (at your option) any * later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @package phpDocumentor * @author Joshua Eichorn <jeichorn@phpdoc.org> * @author Gregory Beaver <cellog@php.net> * @copyright 2000-2006 Joshua Eichorn, Gregory Beaver * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @version CVS: $Id: Io.inc,v 1.12 2006/05/23 13:09:26 cellog Exp $ * @filesource * @link http://www.phpdoc.org * @link http://pear.php.net/PhpDocumentor * @since 0.1 */ /** * Class to handle file and user io opperations * * @author Joshua Eichorn <jeichorn@phpdoc.org> * @author Gregory Beaver <cellog@php.net> * @version $Id: Io.inc,v 1.12 2006/05/23 13:09:26 cellog Exp $ * @package phpDocumentor */ class Io { /** * Holds all the options that are avaible to the cmd line interface * and to the different web interfaces */ var $phpDocOptions; /** * Format: array(array(regexp-ready string to search for whole path, * regexp-ready string to search for basename of ignore strings),...) * @var false|array */ var $ignore = false; /** * creates an array $this->phpDocOptions and sets program options in it. * Array is in the format of: * <pre> * [filename][tag][] = "f"; * [filename][tag][] = "-file"; * [filename][desc] "name of file to parse" * </pre> */ function Io() { $this->phpDocOptions['filename']['tag'] = array( "-f", "--filename"); $this->phpDocOptions['filename']['desc'] = "name of file(s) to parse ',' file1,file2. Can contain complete path and * ? wildcards"; $this->phpDocOptions['filename']['type'] = "path"; $this->phpDocOptions['directory']['tag'] = array( "-d", "--directory"); $this->phpDocOptions['directory']['desc'] = "name of a directory(s) to parse directory1,directory2"; $this->phpDocOptions['directory']['type'] = "path"; $this->phpDocOptions['examplesdir']['tag'] = array( "-ed", "--examplesdir"); $this->phpDocOptions['examplesdir']['desc'] = "full path of the directory to look for example files from @example tags"; $this->phpDocOptions['examplesdir']['type'] = "path"; $this->phpDocOptions['templatebase']['tag'] = array( "-tb", "--templatebase"); $this->phpDocOptions['templatebase']['desc'] = "base location of all templates for this parse."; $this->phpDocOptions['templatebase']['type'] = "path"; $this->phpDocOptions['target']['tag'] = array("-t", "--target"); $this->phpDocOptions['target']['desc'] = "path where to save the generated files"; $this->phpDocOptions['target']['type'] = "path"; $this->phpDocOptions['ignore']['tag'] = array("-i", "--ignore"); $this->phpDocOptions['ignore']['desc'] = "file(s) that will be ignored, multiple separated by ','. Wildcards * and ? are ok"; $this->phpDocOptions['ignore']['type'] = "path"; $this->phpDocOptions['ignoretags']['tag'] = array("-it", "--ignore-tags"); $this->phpDocOptions['ignoretags']['desc'] = "tags to ignore for this parse. @package, @subpackage, @access and @ignore may not be ignored."; $this->phpDocOptions['ignoretags']['type'] = "value"; $this->phpDocOptions['hidden']['tag'] = array("-dh", "--hidden"); $this->phpDocOptions['hidden']['desc'] = "set equal to on (-dh on) to descend into hidden directories (directories starting with '.'), default is off"; $this->phpDocOptions['hidden']['type'] = "set"; $this->phpDocOptions['hidden']['validvalues'] = array('on', 'off'); $this->phpDocOptions['quiet']['tag'] = array("-q", "--quiet"); $this->phpDocOptions['quiet']['desc'] = "do not display parsing/conversion messages. Useful for cron jobs on/off default off"; $this->phpDocOptions['quiet']['type'] = "set"; $this->phpDocOptions['quiet']['validvalues'] = array('on', 'off'); $this->phpDocOptions['title']['tag'] = array("-ti","--title"); $this->phpDocOptions['title']['desc'] = "title of generated documentation, default is 'Generated Documentation'"; $this->phpDocOptions['title']['type'] = "value"; $this->phpDocOptions['help']['tag'] = array("-h", "--help"); $this->phpDocOptions['help']['desc'] = " show this help message"; $this->phpDocOptions['useconfig']['tag'] = array("-c","--useconfig"); $this->phpDocOptions['useconfig']['desc'] = "Use a Config file in the users/ subdirectory for all command-line options"; $this->phpDocOptions['useconfig']['type'] = "value"; $this->phpDocOptions['parseprivate']['tag'] = array("-pp","--parseprivate"); $this->phpDocOptions['parseprivate']['desc'] = "parse @internal and elements marked private with @access. Use on/off, default off"; $this->phpDocOptions['parseprivate']['type'] = "set"; $this->phpDocOptions['parseprivate']['validvalues'] = array('on', 'off'); $this->phpDocOptions['packageoutput']['tag'] = array("-po","--packageoutput"); $this->phpDocOptions['packageoutput']['desc'] = "output documentation only for selected packages. Use a comma-delimited list"; $this->phpDocOptions['packageoutput']['type'] = "value"; $this->phpDocOptions['defaultpackagename']['tag'] = array("-dn","--defaultpackagename"); $this->phpDocOptions['defaultpackagename']['desc'] = "name to use for the default package. If not specified, uses 'default'"; $this->phpDocOptions['defaultpackagename']['type'] = "value"; $this->phpDocOptions['defaultcategoryname']['tag'] = array("-dc","--defaultcategoryname"); $this->phpDocOptions['defaultcategoryname']['desc'] = "name to use for the default category. If not specified, uses 'default'"; $this->phpDocOptions['defaultcategoryname']['type'] = "value"; $this->phpDocOptions['output']['tag'] = array("-o","--output"); $this->phpDocOptions['output']['desc'] = "output information to use separated by ','. Format: output:converter:templatedir like \"HTML:frames:phpedit\""; $this->phpDocOptions['output']['type'] = "value"; $this->phpDocOptions['converterparams']['tag'] = array("-cp","--converterparams"); $this->phpDocOptions['converterparams']['desc'] = "dynamic parameters for a converter, separate values with commas"; $this->phpDocOptions['converterparams']['type'] = "value"; $this->phpDocOptions['customtags']['tag'] = array("-ct","--customtags"); $this->phpDocOptions['customtags']['desc'] = "custom tags, will be recognized and put in tags[] instead of unknowntags[]"; $this->phpDocOptions['customtags']['type'] = "value"; $this->phpDocOptions['sourcecode']['tag'] = array("-s","--sourcecode"); $this->phpDocOptions['sourcecode']['desc'] = "generate highlighted sourcecode for every parsed file (PHP 4.3.0+ only) on/off default off"; $this->phpDocOptions['sourcecode']['type'] = "set"; $this->phpDocOptions['sourcecode']['validvalues'] = array('on', 'off'); $this->phpDocOptions['javadocdesc']['tag'] = array("-j","--javadocdesc"); $this->phpDocOptions['javadocdesc']['desc'] = "JavaDoc-compliant description parsing. Use on/off, default off (more flexibility)"; $this->phpDocOptions['javadocdesc']['type'] = "set"; $this->phpDocOptions['javadocdesc']['validvalues'] = array('on', 'off'); $this->phpDocOptions['pear']['tag'] = array("-p","--pear"); $this->phpDocOptions['pear']['desc'] = "Parse a PEAR-style repository (package is directory, _members are @access private) on/off default off"; $this->phpDocOptions['pear']['type'] = "set"; $this->phpDocOptions['pear']['validvalues'] = array('on', 'off'); $this->phpDocOptions['readmeinstallchangelog']['tag'] = array("-ric","--readmeinstallchangelog"); $this->phpDocOptions['readmeinstallchangelog']['desc'] = "Specify custom filenames to parse like README, INSTALL or CHANGELOG files"; $this->phpDocOptions['readmeinstallchangelog']['type'] = "value"; $this->phpDocOptions['general']['message'] ="You can have multiple directories and multiple files, as well as a combination of both options"; } /** * create the help message for display on the command-line * @return string a string containing a help message */ function displayHelpMsg() { unset($ret); $ret = "\n"; foreach($this->phpDocOptions as $data) { unset($tag); $tag = ""; if (isset($data['tag'])) { if (is_array($data['tag'])) { foreach($data['tag'] as $param) { $tag .= "$param "; } } $taglen = 34; $outputwidth = 79; $tagspace = str_repeat(" ",$taglen); $tmp = " ".trim($tag).$tagspace; $tmp = substr($tmp,0,$taglen); $d = wordwrap(ltrim($data['desc']),($outputwidth-$taglen)); $dt = explode("\n",$d); $dt[0] = $tmp .$dt[0]; for($i=1;$i<count($dt);$i++) { $dt[$i] = $tagspace.$dt[$i]; } $ret .= implode("\n",$dt)."\n\n"; } } $ret .= "\n".wordwrap($data['message'],$outputwidth)."\n"; return $ret; } /** * calls {@link file_exists()} for each value in include_path, * then calls {@link is_readable()} when it finds the file * @param string * @return boolean */ function isIncludeable($filename) { $test = realpath($filename); if ($test && is_readable($test)) { return true; // for absolute paths
} $ip = get_include_path(); if (PHPDOCUMENTOR_WINDOWS) { $ip = explode(';', $ip); } else { $ip = explode(':', $ip)
|