cvs: phpdoc /scripts/docgen book.tpl class.tpl configure.tpl constants.tpl docgen.php examples.tpl function.tpl ini.tpl method.tpl reference.tpl
setup.tpl

From: Date: Wed, 28 May 2008 01:14:24 +0000
Subject: cvs: phpdoc /scripts/docgen book.tpl class.tpl configure.tpl constants.tpl docgen.php examples.tpl function.tpl ini.tpl method.tpl reference.tpl
setup.tpl
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-1702@lists.php.net to get a copy of this message
felipe Wed May 28 01:14:24 2008 UTC Added files: /phpdoc/scripts/docgen book.tpl class.tpl configure.tpl constants.tpl docgen.php examples.tpl function.tpl ini.tpl method.tpl reference.tpl setup.tpl Log: - Added new script (doc generator)

http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/book.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/book.tpl +++ phpdoc/scripts/docgen/book.tpl <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <book xml:id="book.{EXT_NAME_ID}" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>{EXT_NAME}</title> <titleabbrev>{EXT_NAME}</titleabbrev> <preface xml:id="intro.{EXT_NAME_ID}"> &reftitle.intro; <para> Description here. </para> </preface> &reference.{EXT_NAME_ID}.setup; &reference.{EXT_NAME_ID}.constants; &reference.{EXT_NAME_ID}.reference; </book> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/class.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/class.tpl +++ phpdoc/scripts/docgen/class.tpl <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference xml:id="class.{CLASS_NAME_ID}" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"> <title>The {CLASS_NAME} class</title> <titleabbrev>{CLASS_NAME}</titleabbrev> <partintro> <!-- {{{ {CLASS_NAME} intro --> <section xml:id="{CLASS_NAME_ID}.intro"> &reftitle.intro; <para> Description of the class. </para> </section> <!-- }}} --> <section xml:id="{CLASS_NAME_ID}.synopsis"> &reftitle.classsynopsis; <!-- {{{ Synopsis --> <classsynopsis> <ooclass><classname>{CLASS_NAME}</classname></ooclass> <!-- {{{ Class synopsis --> <classsynopsisinfo> <ooclass> <classname>{CLASS_NAME}</classname> </ooclass> {EXTENDS} {IMPLEMENTS} </classsynopsisinfo> <!-- }}} --> {CONSTANTS_LIST} {PROPERTIES_LIST} {METHOD_XINCLUDE} {INHERITED_XINCLUDE} </classsynopsis> <!-- }}} --> </section> {PROPERTIES} {CONSTANTS} </partintro> &reference.{EXT_NAME_ID}.entities.{CLASS_NAME_ID}; </reference> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/configure.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/configure.tpl +++ phpdoc/scripts/docgen/configure.tpl <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <section xml:id="{EXT_NAME_ID}.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.install; <!-- There are various PECL related entities in language-snippets.ent --> <para> To enable {EXT_NAME} support, configure PHP with ... </para> <para> Windows users ... </para> </section> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/constants.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/constants.tpl +++ phpdoc/scripts/docgen/constants.tpl <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <appendix xml:id="{EXT_NAME_ID}.constants" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.constants; {CONSTANTS} </appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/docgen.php?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/docgen.php +++ phpdoc/scripts/docgen/docgen.php <?php /* +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2008 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Felipe Pena <felipe@php.net> | +----------------------------------------------------------------------+ $Id: docgen.php,v 1.1 2008/05/28 01:14:24 felipe Exp $ */ if (!(extension_loaded('reflection') & extension_loaded('pcre'))) { die("To run this script is necessary the Reflection and PCRE extensions\n"); } /* Constants */ define('DOC_METHOD', 1<<0); define('DOC_PROPERTY', 1<<1); define('DOC_CLASS', 1<<2); define('DOC_EXTENSION', 1<<3); define('DOC_FUNCTION', 1<<4); /* Templates */ $TEMPLATE = array( DOC_METHOD => 'method.tpl', DOC_PROPERTY => 'property.tpl', DOC_CLASS => 'class.tpl', DOC_FUNCTION => 'function.tpl' ); /* Default files for extensions */ $DOC_EXT = array( 'book.xml' => 'book.tpl', 'setup.xml' => 'setup.tpl', 'constants.xml' => 'constants.tpl', 'configure.xml' => 'configure.tpl', 'examples.xml' => 'examples.tpl', 'reference.xml' => 'reference.tpl', 'ini.xml' => 'ini.tpl' ); function usage() { /* {{{ */ print <<<USAGE Usage: php refldoc.php <options> Examples: -e date (all extension) -f preg_replace (a function) -c simplexmlelement -m xpath -m asxml (a class method) Options: -c,--class -- class name -e,--extension -- extension name -h,--help -- show this help -m,--method -- method name (require -c) -o,--output -- output dir -v,--version -- show the version -V,--verbose -- disable show progress USAGE; } /* }}} */ function add_warning($err_msg) { /* {{{ */ global $WARNING, $INFO; $WARNING[$INFO['actual_file']][] = $err_msg; } /* }}} */ function create_markup_to_modifiers(ReflectionMethod $method) { /* {{{ */ if ($method->isConstructor()) { return ''; } $modifiers = Reflection::getModifierNames($method->getModifiers()); $markup = ''; if ($modifiers) { foreach ($modifiers as $modifier) { $markup .= '<modifier>'. $modifier .'</modifier> '; } } return $markup; } /* }}} */ function format_id($name) { /* {{{ */ return preg_replace(array('/[^[:alnum:]]/', '/^-+/'), array('-', ''), strtolower($name)); } /* }}} */ function format_filename($name) { /* {{{ */ return preg_replace('/^_+/', '', strtolower($name)); } /* }}} */ function format_config($name) { /* {{{ */ return preg_replace('/_/', '-', $name); } /* }}} */ function get_ident_size($placeholder, $content) { /* {{{ */ preg_match('/^([[:blank:]]*)\{'. $placeholder .'\}/m', $content, $match); return isset($match[1]) ? strlen($match[1]) : false; } /* }}} */ function save_file($filename, &$content) { /* {{{ */ global $OPTION; file_put_contents($filename, $content); if ($OPTION['verbose']) { printf("%s\n", $filename); } } /* }}} */ function get_type_by_string($str) { /* {{{ */ if (is_numeric($str)) { if ($str && intval($str) == $str) { return 'integer'; } else if ($str && floatval($str) == $str) { return 'float'; } else { return 'integer'; } } else { return 'string'; } } /* }}} */ function create_dir($path) { /* {{{ */ global $OPTION; if (!file_exists($path)) { if ($OPTION['verbose']) { printf("- Creating directory `%s'\n", $path); } if (!mkdir($path, 0777)) { add_warning("chmod: Permission denied `{$path}'"); return; } } } /* }}} */ function create_markup_to_params(array $params, $ident) { /* {{{ */ $count = 1; foreach ($params as $param) { /* Parameter type */ if (preg_match('/(\w+) \$/', (string) $param, $match)) { /* 'array or NULL' is used for array type-hint */ $type = $match[1] == 'NULL' ? 'array' : $match[1]; } else { $type = 'string'; if (!$param->getName()) { add_warning(sprintf("Parameter name not found, param%d used", $count)); } add_warning(sprintf("Type hint for parameter `%s' not found, 'string' used", ($param->getName() ? $param->getName() : $count))); } $markup .= sprintf("%s<methodparam%s><type>%s</type><parameter%s>%s</parameter></methodparam>\n", ($markup ? str_repeat(' ', $ident) : ''), ($param->isOptional() ? ' choice="opt"' : ''), $type, ($param->isPassedByReference() ? ' role="reference"' : ''), ($param->getName() ? $param->getName() : 'param'. $count)); $count++; } return rtrim($markup, "\n"); } /* }}} */ function global_check($content) { /* {{{ */ global $INFO; if (!$INFO['actual_extension']) { $INFO['actual_extension'] = 'EXTENSION_NAME_HERE'; } /* {EXT_NAME_ID} */ $content = preg_replace('/\{EXT_NAME_ID\}/', $INFO['actual_extension'], $content); /* {EXT_NAME} */ $content = preg_replace('/\{EXT_NAME\}/', ucwords($INFO['actual_extension']), $content); return $content; } /* }}} */ function create_markup_to_parameter_section(Reflector $obj, $content) { /* {{{ */ /* {PARAMETERS} */ if ($obj->getNumberOfParameters()) { $ident = get_ident_size('PARAMETERS', $content); $parameters = $obj->getParameters(); $content = preg_replace('/\{PARAMETERS\}/', create_markup_to_params($parameters, $ident), $content); /* {PARAMETERS_DESCRIPTION} */ if ($ident = get_ident_size('PARAMETERS_DESCRIPTION', $content)) { $count = 1; $markup = "<para>\n"; $markup .= str_repeat(' ', $ident + 1) ."<variablelist>\n"; foreach ($parameters as $param) { $markup .= str_repeat(' ', $ident + 2) ."<varlistentry>\n"; $markup .= str_repeat(' ', $ident + 3) .'<term><parameter>'. ($param->getName() ? $param->getName() : 'param'. $count) ."</parameter></term>\n"; $markup .= str_repeat(' ', $ident + 3) ."<listitem>\n"; $markup .= str_repeat(' ', $ident + 4) ."<para>\n"; $markup .= str_repeat(' ', $ident + 5) ."Description...\n"; $markup .= str_repeat(' ', $ident + 4) ."</para>\n"; $markup .= str_repeat(' ', $ident + 3) ."</listitem>\n"; $markup .= str_repeat(' ', $ident + 2) ."</varlistentry>\n"; $count++; } $markup .= str_repeat(' ', $ident + 1) ."</variablelist>\n"; $markup .= str_repeat(' ', $ident) ."</para>\n"; $content = preg_replace('/\{PARAMETERS_DESCRIPTION\}/', $markup, $content, 1); } } else { $content = preg_replace('/\{PARAMETERS\}/', '<void />', $content, 1); $content = preg_replace('/\{PARAMETERS_DESCRIPTION\}/', '&no.function.parameters;', $content, 1); } return $content; } /* }}} */ function gen_function_markup(ReflectionFunction $function, $content) { /* {{{ */ /* {FUNCTION_NAME_ID} */ $content = preg_replace('/\{FUNCTION_NAME_ID\}/', format_id($function->getName()), $content); /* {FUNCTION_NAME} */ $content = preg_replace('/\{FUNCTION_NAME\}/', $function->getName(), $content); /* {PARAMETERS}, {PARAMETERS_DESCRIPTION} */ $content = create_markup_to_parameter_section($function, $content); return $content; } /* }}} */ function gen_method_markup(ReflectionMethod $method, $content) { /* {{{ */ /* {PARAMETER}, {PARAMETERS_DESCRIPTION} */ $content = create_markup_to_parameter_section($method, $content); /* {CLASS_NAME_ID} */ $content = preg_replace('/\{CLASS_NAME_ID\}/', format_id($method->class), $content); /* {METHOD_NAME_ID} */ $content = preg_replace('/\{METHOD_NAME_ID\}/', format_id($method->name), $content); /* {FULL_METHOD_NAME} */ $content = preg_replace('/\{FULL_METHOD_NAME\}/', $method->class .'::'. $method->name, $content); /* {METHOD_NAME} */ $content = preg_replace('/\{METHOD_NAME\}/', $method->name, $content); /* {MODIFIERS} */ $content = preg_replace('/\{MODIFIERS\}/', create_markup_to_modifiers($method), $content, 1); /* {RETURN_TYPE} */ if (!$method->isConstructor()) { $content = preg_replace('/\{RETURN_TYPE\}/', '<type>void</type>', $content, 1); } else { $content = preg_replace('/\{RETURN_TYPE\}/', '', $content, 1); } return $content; } /* }}} */ function gen_class_markup(ReflectionClass $class, $content) { /* {{{ */ $id = format_id($class->getName()); /* {CLASS_NAME} */ $content = preg_replace('/\{CLASS_NAME\}/', $class->getName(), $content); /* {CLASS_NAME_ID} */ $content = preg_replace('/{CLASS_NAME_ID\}/', $id, $content); /* {EXTENDS} */ if ($parent = $class->getParentClass()) { $ident = get_ident_size('EXTENDS', $content); $markup = "\n"; $markup .= str_repeat(' ', $ident) . "<ooclass>\n"; $markup .= str_repeat(' ', $ident + 1) ."<modifier>extends</modifier>\n"; $markup .= str_repeat(' ', $ident + 1) .'<classname>'. $parent->getName() ."</classname>\n"; $markup .= str_repeat(' ', $ident) .'</ooclass>'; $content = preg_replace('/\{EXTENDS\}/', $markup, $content, 1); } else { $content = preg_replace('/^\s*\{EXTENDS\}.*?\n/m', '', $content, 1); } /* {IMPLEMENTS} */ if ($interfaces = $class->getInterfaces()) { $ident = get_ident_size('IMPLEMENTS', $content); $markup = "\r"; foreach ($interfaces as $interface) { $markup .= str_repeat(' ', $ident) ."<oointerface>\n"; $markup .= str_repeat(' ', $ident + 1) .'<interfacename>'. $interface->getName() ."</interfacename>\n"; $markup .= str_repeat(' ', $ident) ."</oointerface>\n\n"; } $content = preg_replace('/\{IMPLEMENTS\}/', rtrim($markup, "\n"), $content, 1); } else { $content = preg_replace('/^\s*\{IMPLEMENTS\}.*?\n/m', '', $content, 1); } /* {CONSTANTS_LIST} */ if ($constants = $class->getConstants()) { $ident = get_ident_size('CONSTANTS_LIST', $content); $markup = "<classsynopsisinfo role=\"comment\">Constants</classsynopsisinfo>\n"; foreach ($constants as $constant => $value) { $markup .= str_repeat(' ', $ident) ."<fieldsynopsis>\n"; $markup .= str_repeat(' ', $ident + 1) ."<modifier>const</modifier>\n"; $markup .= str_repeat(' ', $ident + 1) .'<type>'. gettype($value) ."</type>\n"; $markup .= str_repeat(' ', $ident + 1) .'<varname linkend="'. $id .'.constants.'. format_id($constant) .'">'. $class->getName() .'::'. $constant ."</varname>\n"; $markup .= str_repeat(' ', $ident + 1) .'<initializer>'. $value ."</initializer>\n"; $markup .= str_repeat(' ', $ident) ."</fieldsynopsis>\n"; } $content = preg_replace('/\{CONSTANTS_LIST\}/', $markup, $content, 1); } else { $content = preg_replace('/^\s*\{CONSTANTS_LIST\}.*?\n/m', '', $content, 1); } /* {CONSTANTS} */ if ($constants) { $ident = get_ident_size('CONSTANTS', $content); $markup = "\r<!-- {{{ ". $class->getName() ." constants -->\n"; $markup .= str_repeat(' ', $ident) .'<section xml:id="'. $id .".constants\">\n"; $markup .= str_repeat(' ', $ident + 1) ."&reftitle.constants;\n"; $markup .= str_repeat(' ', $ident + 1) .'<section xml:id="'. $id .".constants.types\">\n"; $markup .= str_repeat(' ', $ident + 2) .'<title>'. $class->getName() ." Node Types</title>\n"; $markup .= str_repeat(' ', $ident + 2) ."<variablelist>\n\n"; foreach ($constants as $constant => $value) { $markup .= str_repeat(' ', $ident + 3) .'<varlistentry xml:id="'. $id .".constants.none\">\n"; $markup .= str_repeat(' ', $ident + 4) .'<term><constant>'. $class->getName() .'::'. $constant ."</constant></term>\n"; $markup .= str_repeat(' ', $ident + 4) ."<listitem>\n"; $markup .= str_repeat(' ', $ident + 5) ."<para>Description here...</para>\n"; $markup .= str_repeat(' ', $ident + 4) ."</listitem>\n"; $markup .= str_repeat(' ', $ident + 3) ."</varlistentry>\n\n"; } $markup .= str_repeat(' ', $ident + 2) ."</variablelist>\n"; $markup .= str_repeat(' ', $ident) ."</section>\n"; $markup .= "<!-- }}} -->\n"; $content = preg_replace('/\{CONSTANTS\}/', $markup, $content, 1); } else { $content = preg_replace('/^\s*\{CONSTANTS\}.*?\n/m', '', $content, 1); } /* {PROPERTIES_LIST} */ if ($properties = $class->getProperties()) { $ident = get_ident_size('PROPERTIES_LIST', $content); $markup = "<classsynopsisinfo role=\"comment\">Properties</classsynopsisinfo>\n"; foreach ($properties as $property) { /* Don't get inherited properties */ if ($property->getDeclaringClass()->name != $class->name) { continue; } /* Get the modifier */ preg_match('/(\w+) \$/', (string) $property, $match); $markup .= str_repeat(' ', $ident) ."<fieldsynopsis>\n"; $markup .= str_repeat(' ', $ident + 1) .'<modifier>'. $match[1] ."</modifier>\n"; $markup .= str_repeat(' ', $ident + 1) .'<varname linkend="'. $id .'.props.'. $property->getName() .'">'. $property->getName() ."</varname>\n"; $markup .= str_repeat(' ', $ident) ."</fieldsynopsis>\n"; } $content = preg_replace('/\{PROPERTIES_LIST\}/', $markup, $content, 1); } else { $content = preg_replace('/^\s*\{PROPERTIES_LIST\}.*?\n/m', '', $content, 1); } /* {PROPERTIES} */ if ($properties) { $ident = get_ident_size('PROPERTIES', $content); $markup = "\r<!-- {{{ ". $class->getName() ." properties -->\n"; $markup .= str_repeat(' ', $ident) ."<section xml:id=\"". $id .".props\">\n"; $markup .= str_repeat(' ', $ident + 1) ."&reftitle.properties;\n"; $markup .= str_repeat(' ', $ident + 1) ."<variablelist>\n"; foreach ($properties as $property) { $markup .= str_repeat(' ', $ident + 2) .'<varlistentry xml:id="'. $id .'.props.'. $property->getName() ."\">\n"; $markup .= str_repeat(' ', $ident + 3) .'<term><varname>'. $property->getName() ."</varname></term>\n"; $markup .= str_repeat(' ', $ident + 3) ."<listitem>\n"; $markup .= str_repeat(' ', $ident + 4) ."<para>Prop description</para>\n"; $markup .= str_repeat(' ', $ident + 3) ."</listitem>\n"; $markup .= str_repeat(' ', $ident + 2) ."</varlistentry>\n"; } $markup .= str_repeat(' ', $ident + 1) ."</variablelist>\n"; $markup .= str_repeat(' ', $ident) ."</section>\n"; $markup .= "<!-- }}} -->\n"; $content = preg_replace('/\{PROPERTIES\}/', $markup, $content, 1); } else { $content = preg_replace('/^\s*\{PROPERTIES\}.*?\n/m', '', $content, 1); } /* {PROPERTY_XINCLUDE} */ $content = preg_replace('/\{PROPERTY_XINCLUDE\}/', "<xi:include xpointer=\"xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.". $id ."')/db:refentry/db:refsect1[@role='description']/descendant::db:fieldsynopsis[1])\" />\n", $content, 1); /* {METHOD_XINCLUDE} */ $ident = get_ident_size('METHOD_XINCLUDE', $content); $content = preg_replace('/\{METHOD_XINCLUDE\}/', "\n". str_repeat(' ', $ident) . "<classsynopsisinfo role=\"comment\">Methods</classsynopsisinfo>\n". str_repeat(' ', $ident) ."<xi:include xpointer=\"xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.". $id ."')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])\" />", $content, 1); /* {INHERITED_XINCLUDE} */ if ($parent) { $ident = get_ident_size('INHERITED_XINCLUDE', $content); $content = preg_replace('/\{INHERITED_XINCLUDE\}/', "\n". str_repeat(' ', $ident) ."<classsynopsisinfo role=\"comment\">Inherited methods</classsynopsisinfo>\n". str_repeat(' ', $ident) ."<xi:include xpointer=\"xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.". format_id($parent->getName()) ."')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])\" />\n", $content, 1); } else { $content = preg_replace('/^\s*\{INHERITED_XINCLUDE\}.*?\n/m', '', $content, 1); } return $content; } /* }}} */ function gen_extension_markup(ReflectionExtension $obj, $content, $xml_file) { /* {{{ */ global $INFO; switch ($xml_file) { case 'ini.xml': if ($ini = $obj->getINIEntries()) { $ident = get_ident_size('INI_ENTRIES', $content); $markup = "<tbody>\n";; $markup2 = ''; foreach ($ini as $config => $value) { $markup .= str_repeat(' ', $ident + 1) ."<row>\n"; $markup .= str_repeat(' ', $ident + 2) ."<entry>". $config ."</entry>\n"; $markup .= str_repeat(' ', $ident + 2) ."<entry>". $value ."</entry>\n"; $markup .= str_repeat(' ', $ident + 2) ."<entry>its PHP_INI_* value</entry>\n"; $markup .= str_repeat(' ', $ident + 2) ."<entry>leave empty. this will be fiiled by an automatic script</entry>\n"; $markup .= str_repeat(' ', $ident + 1) ."</row>\n"; $markup2 .= ($markup2 ? str_repeat(' ', $ident) : '') ."<varlistentry xml:id=\"ini.". format_config($config) ."\">\n"; $markup2 .= str_repeat(' ', $ident + 1) ."<term>\n"; $markup2 .= str_repeat(' ', $ident + 2) ."<parameter>". $config ."</parameter>\n"; $markup2 .= str_repeat(' ', $ident + 2) ."<type>". get_type_by_string($value) ."</type>\n"; $markup2 .= str_repeat(' ', $ident + 1) ."</term>\n"; $markup2 .= str_repeat(' ', $ident + 1) ."<listitem>\n"; $markup2 .= str_repeat(' ', $ident + 2) ."<para>\n"; $markup2 .= str_repeat(' ', $ident + 3) ."Description here...\n"; $markup2 .= str_repeat(' ', $ident + 2) ."</para>\n"; $markup2 .= str_repeat(' ', $ident + 1) ."</listitem>\n"; $markup2 .= str_repeat(' ', $ident) ."</varlistentry>\n"; } $markup .= "</tbody>"; /* {INI_ENTRIES} */ $content = preg_replace('/\{INI_ENTRIES\}/', $markup, $content, 1); /* {INI_ENTRIES_DESCRIPTION} */ $content = preg_replace('/\{INI_ENTRIES_DESCRIPTION\}/', $markup2, $content, 1); } else { return false; /* Abort */ } break; case 'constants.xml': if ($constants = $obj->getConstants()) { $ident = get_ident_size('CONSTANTS', $content); $markup = "&extension.constants;\n"; $markup .= str_repeat(' ', $ident) ."<para>\n"; $markup .= str_repeat(' ', $ident + 1) ."<variablelist>\n"; foreach ($constants as $name => $value) { $markup .= str_repeat(' ', $ident + 2) ."<varlistentry>\n"; $markup .= str_repeat(' ', $ident + 3) ."<term>\n"; $markup .= str_repeat(' ', $ident + 4) ."<constant>". $name ."</constant>\n"; $markup .= str_repeat(' ', $ident + 4) ."(<type>". gettype($value) ."</type>)\n"; $markup .= str_repeat(' ', $ident + 3) ."</term>\n"; $markup .= str_repeat(' ', $ident + 3) ."<listitem>\n"; $markup .= str_repeat(' ', $ident + 4) ."<simpara>\n"; $markup .= str_repeat(' ', $ident + 4) ."</simpara>\n"; $markup .= str_repeat(' ', $ident + 3) ."</listitem>\n"; $markup .= str_repeat(' ', $ident + 2) ."</varlistentry>\n"; } $markup .= str_repeat(' ', $ident + 1) ."</variablelist>\n"; $markup .= str_repeat(' ', $ident) ."</para>"; $content = preg_replace('/\{CONSTANTS\}/', $markup, $content, 1); } else { $content = preg_replace('/\{CONSTANTS\}/', '&no.constants;', $content, 1); } break; } return $content; } /* }}} */ function get_extension_name($string) { /* {{{ */ preg_match('/<[^:]+:([^>]+)/', $string, $match); return isset($match[1]) ? format_id($match[1]) : false; } /* }}} */ function write_doc(Reflector $obj, $type) { /* {{{ */ global $OPTION, $INFO, $TEMPLATE, $DOC_EXT; switch ($type) { case DOC_EXTENSION: foreach ($DOC_EXT as $xml_file => $tpl_file) { $filename = $OPTION['output'] .'/'. $xml_file; $INFO['actual_file'] = $filename; $content = file_get_contents(dirname(__FILE__) .'/'. $tpl_file); if ($content = gen_extension_markup($obj, $content, $xml_file)) { save_file($filename, global_check($content)); } } break; /* Methods */ case DOC_METHOD: $path = $OPTION['output'] .'/'. strtolower($obj->class); $filename = $path .'/'. format_filename($obj->name) .'.xml'; create_dir($path); $INFO['actual_file'] = $filename; $content = file_get_contents(dirname(__FILE__) .'/'. $TEMPLATE[$type]); $content = gen_method_markup($obj, $content); save_file($filename, global_check($content)); break; /* Properties */ case DOC_PROPERTY: /* Doesn't exists separated file documenting property, actually * they are documented in DOC_METHOD */ break; /* Classes */ case DOC_CLASS: $path = $OPTION['output']; $filename = $path .'/'. strtolower($obj->getName()) .'.xml'; $INFO['actual_file'] = $filename; $content = file_get_contents(dirname(__FILE__) .'/'. $TEMPLATE[$type]); $content = gen_class_markup($obj, $content); /* classname.xml */ save_file($filename, global_check($content)); break; case DOC_FUNCTION: $path = $OPTION['output'] .'/functions'; $filename = $path .'/'. $obj->getName() .'.xml'; $INFO['actual_file'] = $filename; create_dir($path); $content = file_get_contents(dirname(__FILE__) .'/'. $TEMPLATE[$type]); $content = gen_function_markup($obj, $content); save_file($filename, global_check($content)); break; } } /* }}} */ function gen_docs($name, $type) { /* {{{ */ global $OPTION, $INFO; if ($type & DOC_EXTENSION) { try { $extension = new ReflectionExtension($name); $INFO['actual_extension'] = format_id($name); write_doc($extension, DOC_EXTENSION); foreach ($extension->getClasses() as $class) { gen_docs($class->name, DOC_CLASS); } foreach ($extension->getFunctions() as $function) { gen_docs($function->name, DOC_FUNCTION); } } catch (Exception $e) { die('Error: '. $e->getMessage() ."\n"); } } else if ($type & DOC_FUNCTION) { try { $function = new ReflectionFunction($name); if (!$INFO['actual_extension']) { if ($extname = get_extension_name((string) $function)) { $INFO['actual_extension'] = $extname; } else { add_warning("The function {$name} has not information in Reflection about their extension"); } } write_doc($function, DOC_FUNCTION); } catch (Exception $e) { die('Error: '. $e->getMessage() ."\n"); } } else if ($type & DOC_METHOD) { try { $class = new ReflectionClass($OPTION['class']); if (!$INFO['actual_extension']) { if ($extname = get_extension_name((string) $class)) { $INFO['actual_extension'] = $extname; } else { add_warning("The class {$name} has not information in Reflection about their extension"); } } foreach ($class->getMethods() as $method) { /* Don't get the inherited methods */ if ($method->getDeclaringClass()->name == $class->name && ((is_array($OPTION['method']) && in_array(strtolower($method->getName()), $OPTION['method'])) || $OPTION['method'] == strtolower($method->getName()))) { write_doc($method, DOC_METHOD); } } } catch (Exception $e) { die('Error: '. $e->getMessage() ."\n"); } } else if ($type & DOC_CLASS) { try { $class = new ReflectionClass($name); if (!$INFO['actual_extension']) { if ($extname = get_extension_name((string) $class)) { $INFO['actual_extension'] = $extname; } else { add_warning("The class {$name} has not information in Reflection about their extension"); } } write_doc($class, DOC_CLASS); foreach ($class->getMethods() as $method) { /* Don't get the inherited methods */ if ($method->getDeclaringClass()->name == $class->name) { write_doc($method, DOC_METHOD); } } } catch (Exception $e) { die('Error: '. $e->getMessage() ."\n"); } } } /* }}} */ $OPTION = array(); $INFO = array('actual_extension' => false); $WARNING = array(); $OPTION['extension'] = NULL; $OPTION['method'] = NULL; $OPTION['class'] = NULL; $OPTION['function'] = NULL; $OPTION['output'] = getcwd(); $OPTION['verbose'] = true; $OPTION['quiet'] = false; $arropts = array( 'verbose' => 'v', /* version */ 'version' => 'V', /* verbose */ 'quiet' => 'q', /* quiet */ 'help' => 'h', /* help */ 'output:' => 'o:', /* output dir */ 'class:' => 'c:', /* classname */ 'extension:' => 'e:', /* extension */ 'function:' => 'f:', /* function */ 'method:' => 'm:' /* method */ ); $options = getopt(implode($arropts), array_keys($arropts)); if (!$options) { usage(); exit; } foreach ($options as $opt => $value) { switch ($opt) { case 'v': case 'version': printf("%s\n", '$Revision: 1.1 $'); break; case 'V': case 'verbose': $OPTION['verbose'] = false; break; case 'h': case 'help': usage(); break; case 'e': case 'extension': $OPTION['extension'] = $value; break; case 'f': case 'function': $OPTION['function'] = $value; break; case 'm': case 'method': if (!array_key_exists('c', $options) && !array_key_exists('class', $options)) { die("Error: The class name should be supplied (i.e. -c classname)\n"); } $OPTION['method'] = is_array($value) ? array_map('strtolower', $value) : strtolower($value); break; case 'c': case 'class': $OPTION['class'] = $value; break; case 'o': case 'output': if (!file_exists($value) || !is_writable($value)) { die("Error: The directory output must exists and writable\n"); } $OPTION['output'] = $value; break; case 'q': case 'quiet': $OPTION['quiet'] = true; break; } } if (!empty($OPTION['extension'])) { if (is_array($OPTION['extension'])) { foreach ($OPTION['extension'] as $extension) { gen_docs($extension, DOC_EXTENSION); } } else { gen_docs($OPTION['extension'], DOC_EXTENSION); } } if (!empty($OPTION['function'])) { gen_docs($OPTION['function'], DOC_FUNCTION); } if (!empty($OPTION['method'])) { gen_docs($OPTION['method'], DOC_METHOD); } if (empty($OPTION['method']) && !empty($OPTION['class'])) { if (is_array($OPTION['class'])) { foreach ($OPTION['class'] as $classname) { gen_docs($classname, DOC_CLASS); } } else { gen_docs($OPTION['class'], DOC_CLASS); } } /* Warnings */ if (!empty($WARNING) && !$OPTION['quiet']) { print "\nWarnings:\n"; foreach ($WARNING as $file => $messages) { printf("- %s\n", $file); foreach ($messages as $message) { printf("\t-- %s\n", $message); } } } http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/examples.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/examples.tpl +++ phpdoc/scripts/docgen/examples.tpl <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter xml:id="{EXT_NAME_ID}.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.examples; <para> Description here... </para> <example> <title>{EXT_NAME} Example</title> <programlisting role="php"> <![CDATA[ <?php /* ... */ ?> ]]> </programlisting> &example.outputs.similar; <screen> <![CDATA[.... ]]> </screen> </example> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/function.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/function.tpl +++ phpdoc/scripts/docgen/function.tpl <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="function.{FUNCTION_NAME_ID}" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>{FUNCTION_NAME}</refname> <refpurpose>Description</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>{FUNCTION_NAME}</methodname> {PARAMETERS} </methodsynopsis> <para> The function description goes here. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; {PARAMETERS_DESCRIPTION} </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> When does this function issue E_* level errors, and/or throw exceptions. </para> </refsect1> <refsect1 role="unicode"> &reftitle.unicode; <para> Information specific to unicode, from the PHP 6 changes. </para> </refsect1> <refsect1 role="changelog"> &reftitle.changelog; <para> <informaltable> <tgroup cols="2"> <thead> <row> <entry>&Version;</entry> <entry>&Description;</entry> </row> </thead> <tbody> <row> <entry>Enter the version of change here</entry> <entry> Describe the change </entry> </row> </tbody> </tgroup> </informaltable> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>{FUNCTION_NAME}</function> example</title> <para> Any text that describes the purpose of the example, or what goes on in the example should be here. </para> <programlisting role="php"> <![CDATA[ <?php /* ... */ ?> ]]> </programlisting> &example.outputs.similar; <screen> <![CDATA[.... ]]> </screen> </example> </para> </refsect1> <refsect1 role="notes"> &reftitle.notes; <caution> <para> Any notes that don't fit anywhere else should go here. 90% of the time, notes, warnings or cautions are better placed in the parameters section. Consider that before using this section! </para> </caution> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>related function name here</function></member> </simplelist> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/ini.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/ini.tpl +++ phpdoc/scripts/docgen/ini.tpl <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <section xml:id="{EXT_NAME_ID}.configuration" xmlns="http://docbook.org/ns/docbook"> &reftitle.runtime; &extension.runtime; <para> <table> <title>{EXT_NAME} &ConfigureOptions;</title> <tgroup cols="4"> <thead> <row> <entry>&Name;</entry> <entry>&Default;</entry> <entry>&Changeable;</entry> <entry>Changelog</entry> </row> </thead> {INI_ENTRIES} </tgroup> </table> </para> &ini.descriptions.title; <para> <variablelist> {INI_ENTRIES_DESCRIPTION} </variablelist> </para> </section> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/method.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/method.tpl +++ phpdoc/scripts/docgen/method.tpl <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="{CLASS_NAME_ID}.{METHOD_NAME_ID}" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>{FULL_METHOD_NAME}</refname> <refpurpose>The {METHOD_NAME} purpose</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> {MODIFIERS}{RETURN_TYPE}<methodname>{FULL_METHOD_NAME}</methodname> {PARAMETERS} </methodsynopsis> <para> The method description goes here. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; {PARAMETERS_DESCRIPTION} </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Description... </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>{FULL_METHOD_NAME}</function> example</title> <programlisting role="php"> <![CDATA[ <?php /* ... */ ?> ]]> </programlisting> &example.outputs.similar; <screen> <![CDATA[.... ]]> </screen> </example> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/reference.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/reference.tpl +++ phpdoc/scripts/docgen/reference.tpl <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <reference xml:id="ref.{EXT_NAME_ID}" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>{EXT_NAME} &Functions;</title> &reference.{EXT_NAME_ID}.entities.functions; </reference> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc/scripts/docgen/setup.tpl?view=markup&rev=1.1 Index: phpdoc/scripts/docgen/setup.tpl +++ phpdoc/scripts/docgen/setup.tpl <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter xml:id="{EXT_NAME_ID}.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.setup; <section xml:id="{EXT_NAME_ID}.requirements"> &reftitle.required; <!-- Use &no.requirement; if there no requirement --> <para> Requirements... </para> </section> <!-- {{{ Installation --> &reference.{EXT_NAME_ID}.configure; <!-- }}} --> <!-- {{{ Configuration --> &reference.{EXT_NAME_ID}.ini; <!-- }}} --> <section xml:id="{EXT_NAME_ID}.resources"> &reftitle.resources; <!-- Use &no.resource; if there no resources --> <para> Mention the resource here. </para> </section> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.doc.cvs (#1702) next »