cvs: peardoc /en/package/php/php-compatinfo renderer.xml
| From: | Laurent Laville | Date: | Fri, 01 Aug 2008 14:47:20 +0000 |
| Subject: | cvs: peardoc /en/package/php/php-compatinfo renderer.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-11032@lists.php.net to get a copy of this message | ||
farell Fri Aug 1 14:47:20 2008 UTC
Added files:
/peardoc/en/package/php/php-compatinfo renderer.xml
Log:
-initial commit
explain the new renderer system introduced with API 1.8.0
http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-compatinfo/renderer.xml?view=markup&rev=1.1 Index: peardoc/en/package/php/php-compatinfo/renderer.xml +++ peardoc/en/package/php/php-compatinfo/renderer.xml <!-- $Revision: 1.1 $ --> <refentry id="package.php.php-compatinfo.renderer"> <refnamediv> <refname>Outputting Results</refname> <refpurpose>how to use the renderer system</refpurpose> </refnamediv> <refsect1 id="package.php.php-compatinfo.renderer.overview"> <title>Overview</title> <para> PHP_CompatInfo can use different kind of renderers and provides a default one (Array) which print a complete parsable string representation of results. </para> <para> There are 6 renderers available with PHP_CompatInfo 1.8.0 <itemizedlist> <listitem> <para> <emphasis role="bold">Array</emphasis>, <classname>PHP_CompatInfo_Renderer_Array</classname>. It is similar to PHP <ulink url="&url.php.manual;en/function.var-export.php">var_export</ulink> May be beautify if PEAR::Var_Dump is installed on your system. </para> </listitem> <listitem> <para> <emphasis role="bold">Csv</emphasis>, <classname>PHP_CompatInfo_Renderer_Csv</classname>. Print a comma separate values of results. </para> </listitem> <listitem> <para> <emphasis role="bold">Html</emphasis>, <classname>PHP_CompatInfo_Renderer_Html</classname>. Print a pretty nice table with a customizable style sheet (inline or to a separate file) </para> </listitem> <listitem> <para> <emphasis role="bold">Null</emphasis>, <classname>PHP_CompatInfo_Renderer_Null</classname>. The solution to suppress display on standard output. </para> </listitem> <listitem> <para> <emphasis role="bold">Text</emphasis>, <classname>PHP_CompatInfo_Renderer_Text</classname>. This renderer is usefull only with the command-line parser mode (CLI). </para> </listitem> <listitem> <para> <emphasis role="bold">Xml</emphasis>, <classname>PHP_CompatInfo_Renderer_Xml</classname>. Print an XML representation of results. May be beautify if PEAR::XML_Beautifier is installed on your system. </para> </listitem> </itemizedlist> If none of them match your need, you can also write your own renderers. </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.basic-usage"> <title>Basic usage</title> <para> The main steps of using any available renderer are quite similar: </para> <para> <programlisting role="php"> <![CDATA[ <?php require_once 'PHP/CompatInfo.php'; // data source to parse: file, directory, string, ... $datasource = '/tmp/HTML_CSS-1.5.1'; // parser options depending of data source $options = array(); // kind of renderer: array, csv, html, null, text, xml, ... $driverType = 'array'; // case insensitive // specific renderer hash options $driverOptions = array(); $pci = new PHP_CompatInfo($driverType, $driverOptions); $r = $pci->parseData($datasource, $options); ?> ]]> </programlisting> </para> <para> <note> <para> To keep compatibility with previous versions, you can find the result similar to var_export (Array renderer) in $r (in our example). All parse functions (parseDir, parseFile, parseArray, parseString) have the same behavior. </para> </note> </para> <para> PHP_CompatInfo class constructor expect to receive two parameters: first one identify the kind of renderer (array, csv, html, null, text, xml), while second is private and specific to each renderer. Allows to customize a bit the renderer without to rewrite a new one (explore all options before beginning to write your own version). </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.configuration"> <title>Configuration options</title> <para> Before to have a look on each driver specific options, take a short pause on common options of all renderers. </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">silent</emphasis> mode : When parsing more than one source file, PHP_CompatInfo can display status of long process. With simple wait text messages, or a progress bar if PEAR::Console_ProgressBar is available (installed on your system). </para> <para> The default mode <emphasis>silent On</emphasis>, is turn off when you specify a progress bar or a progress text with --progress or -p switches on CLI with the pci script. </para> <para> If you run the web interface, you have to turn it on manually. For example: <programlisting role="php"> <![CDATA[ <?php require_once 'PHP/CompatInfo.php'; // data source to parse: file, directory, string, ... $datasource = '/tmp/HTML_CSS-1.5.1'; // parser options depending of data source $options = array(); // kind of renderer: array, csv, html, null, text, xml, ... $driverType = 'array'; // case insensitive // Turn Off the silent mode, and display simple wait text messages $driverOptions = array('silent' => false, 'progress' => 'text'); $pci = new PHP_CompatInfo($driverType, $driverOptions); $r = $pci->parseData($datasource, $options); ?> ]]> </programlisting> See also the <filename>docs/examples/parseDir_withCustomProgressBar.php</filename> example in the package distribution, to customize a progress bar for the CLI and pci script usage. </para> </listitem> <listitem> <para> <emphasis role="bold">output-level</emphasis> allow to choose what information (condition code level, extensions, constants, tokens, version) will be shown or hidden. </para> <para> Default value is 31: that means we show all details. See the <link linkend="package.php.php-compatinfo.command-line">Command-Line Parser</link> section, and -o | --output-level switch to learn more about values and corresponding behaviors. </para> </listitem> <listitem> <para> <emphasis role="bold">summarize</emphasis> mode, is usefull when you parse more than one file, and don't want to see intermediate result of each file, but only the final one. </para> <para> Default is turn off. </para> </listitem> <listitem> <para> <emphasis role="bold">verbose</emphasis> level, give details deep you want to have: from 0 (no extra information) to 7 (full details). </para> <para> Default level is 0. See the <link linkend="package.php.php-compatinfo.command-line">Command-Line Parser</link> section, and -v | --verbose switch to learn more about values and corresponding behaviors. </para> </listitem> </itemizedlist> </para> <para> <important> <para> All renderers can be run in both interfaces (web and cli), this is why we can find a hash named <emphasis>args</emphasis> in the driver array options (second parameter of PHP_CompatInfo class constructor). This hash replace corresponding arguments you should have (otherwise) to specify on the Command-Line. </para> </important> </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.array"> <title>Array renderer options</title> <para> Array renderer used two drivers to show dump of results. Default is <literal>PHP</literal> (var_export function). The other one is <literal>PEAR::Var_Dump</literal>. You can use this last one only if package is installed on your system. </para> <para> While there are no specific options for PHP driver, you can use all options of PEAR::Var_Dump to beautify the dump of results. See example <filename>docs/examples/pci180_parsefile.php</filename> in the package distribution. </para> <para> First key of hash (<literal>options</literal>) allow to choose the Var_Dump renderer (display_mode) you want. <caution> <para> Only <emphasis>display_mode = Text</emphasis> is allowed if you run PHP_CompatInfo on CLI. </para> </caution> Second key of hash (<literal>rendererOptions</literal>) allow to give specific options to the Var_Dump renderer identified by display_mode directive. </para> <para> <note> <para> <emphasis role="bold">Var_Dump</emphasis> package exists for two major versions of PHP. </para> <para> <ulink url="http://pear.php.net/package/Var_Dump"> Var_Dump PHP 4 on default PEAR channel </ulink> (branch 1.0) </para> <para> <ulink url="http://toolbox.aldabase.com/index.php?package=Var_Dump"> Var_Dump PHP 5 on PEAR channel Toolbox </ulink> (branch 1.2) </para> </note> </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.csv"> <title>Csv renderer options</title> <para> Csv renderer can be customized only in one way: change delimiters characters </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">fields-values-separated-by</emphasis> identify the delimiter of values when there is a list given (extensions, constants, tokens). Default is <emphasis role="bold">,</emphasis> </para> </listitem> <listitem> <para> <emphasis role="bold">fields-terminated-by</emphasis> identify the delimiter of fields (those given by the output-level directive). Default is <emphasis role="bold">;</emphasis> </para> </listitem> <listitem> <para> <emphasis role="bold">fields-enclosed-by</emphasis> identify the protect field character if content have one or more restrictive character as given by previous options. Default is <emphasis role="bold">"</emphasis> </para> </listitem> <listitem> <para> <emphasis role="bold">lines-terminated-by</emphasis> identify the end-of-line character. Usefull if you want to generate a file for another platform than those who have produced the results. Default is <emphasis role="bold">PHP_EOL constant</emphasis> </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.html"> <title>Html renderer options</title> <para> Html renderer have only one specific option : </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">tdwidth</emphasis> that give size of each column (in em css unit), even if there are not shown (see output-level value). Default is <emphasis role="bold">18,4,2,7,13</emphasis> </para> <para> That means: File is 18 em width, Version is 4 em width, C (cond_code) is 2 em width, Extensions is 7 em width, and Constants/Tokens is 13 em width. </para> </listitem> </itemizedlist> </para> <para> See also the <filename>docs/examples/pci180_parsedir_tohtml.php</filename> example in the package distribution, howto define your own html renderer. </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.text"> <title>Text renderer options</title> <para> Text renderer have only one specific option : </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">colwidth</emphasis> that give size of file (f), extensions (e), and constants/tokens (c) column (in character unit), even if there are not shown (see output-level value). Default is <emphasis role="bold">f = 29, e = 12, c = 20)</emphasis> </para> </listitem> </itemizedlist> </para> <para> See the <link linkend="package.php.php-compatinfo.command-line">Command-Line Parser</link> section, and -t | --tab switch to learn more about optimized values depending of output-level </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.xml"> <title>Xml renderer options</title> <para> Xml renderer have only two specific options : </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">use-beautifier</emphasis> tell if we use the PEAR::XML_Beautifier package to beautify XML output. Default is <emphasis role="bold">auto</emphasis> (use only if available) </para> </listitem> <listitem> <para> <emphasis role="bold">beautifier</emphasis> is a hash for the PEAR::XML_Beautifier package options. Default is empty array (use all XML_Beautifier package default options). </para> </listitem> </itemizedlist> </para> <para> <tip> <para> Use <literal>no</literal> value if you have PEAR::XML_Beautifier installed, and you don't want to have XML beautified. </para> </tip> </para> <para> See also the <filename>docs/examples/pci180_parsedata_toxml.php</filename>, and <filename>docs/examples/pci180_parsestring_toxml.php</filename> examples in the package distribution. </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 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/peardoc/en/package/php/php-compatinfo/renderer.xml?view=markup&rev=1.1 Index: peardoc/en/package/php/php-compatinfo/renderer.xml +++ peardoc/en/package/php/php-compatinfo/renderer.xml <!-- $Revision: 1.1 $ --> <refentry id="package.php.php-compatinfo.renderer"> <refnamediv> <refname>Outputting Results</refname> <refpurpose>how to use the renderer system</refpurpose> </refnamediv> <refsect1 id="package.php.php-compatinfo.renderer.overview"> <title>Overview</title> <para> PHP_CompatInfo can use different kind of renderers and provides a default one (Array) which print a complete parsable string representation of results. </para> <para> There are 6 renderers available with PHP_CompatInfo 1.8.0 <itemizedlist> <listitem> <para> <emphasis role="bold">Array</emphasis>, <classname>PHP_CompatInfo_Renderer_Array</classname>. It is similar to PHP <ulink url="&url.php.manual;en/function.var-export.php">var_export</ulink> May be beautify if PEAR::Var_Dump is installed on your system. </para> </listitem> <listitem> <para> <emphasis role="bold">Csv</emphasis>, <classname>PHP_CompatInfo_Renderer_Csv</classname>. Print a comma separate values of results. </para> </listitem> <listitem> <para> <emphasis role="bold">Html</emphasis>, <classname>PHP_CompatInfo_Renderer_Html</classname>. Print a pretty nice table with a customizable style sheet (inline or to a separate file) </para> </listitem> <listitem> <para> <emphasis role="bold">Null</emphasis>, <classname>PHP_CompatInfo_Renderer_Null</classname>. The solution to suppress display on standard output. </para> </listitem> <listitem> <para> <emphasis role="bold">Text</emphasis>, <classname>PHP_CompatInfo_Renderer_Text</classname>. This renderer is usefull only with the command-line parser mode (CLI). </para> </listitem> <listitem> <para> <emphasis role="bold">Xml</emphasis>, <classname>PHP_CompatInfo_Renderer_Xml</classname>. Print an XML representation of results. May be beautify if PEAR::XML_Beautifier is installed on your system. </para> </listitem> </itemizedlist> If none of them match your need, you can also write your own renderers. </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.basic-usage"> <title>Basic usage</title> <para> The main steps of using any available renderer are quite similar: </para> <para> <programlisting role="php"> <![CDATA[ <?php require_once 'PHP/CompatInfo.php'; // data source to parse: file, directory, string, ... $datasource = '/tmp/HTML_CSS-1.5.1'; // parser options depending of data source $options = array(); // kind of renderer: array, csv, html, null, text, xml, ... $driverType = 'array'; // case insensitive // specific renderer hash options $driverOptions = array(); $pci = new PHP_CompatInfo($driverType, $driverOptions); $r = $pci->parseData($datasource, $options); ?> ]]> </programlisting> </para> <para> <note> <para> To keep compatibility with previous versions, you can find the result similar to var_export (Array renderer) in $r (in our example). All parse functions (parseDir, parseFile, parseArray, parseString) have the same behavior. </para> </note> </para> <para> PHP_CompatInfo class constructor expect to receive two parameters: first one identify the kind of renderer (array, csv, html, null, text, xml), while second is private and specific to each renderer. Allows to customize a bit the renderer without to rewrite a new one (explore all options before beginning to write your own version). </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.configuration"> <title>Configuration options</title> <para> Before to have a look on each driver specific options, take a short pause on common options of all renderers. </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">silent</emphasis> mode : When parsing more than one source file, PHP_CompatInfo can display status of long process. With simple wait text messages, or a progress bar if PEAR::Console_ProgressBar is available (installed on your system). </para> <para> The default mode <emphasis>silent On</emphasis>, is turn off when you specify a progress bar or a progress text with --progress or -p switches on CLI with the pci script. </para> <para> If you run the web interface, you have to turn it on manually. For example: <programlisting role="php"> <![CDATA[ <?php require_once 'PHP/CompatInfo.php'; // data source to parse: file, directory, string, ... $datasource = '/tmp/HTML_CSS-1.5.1'; // parser options depending of data source $options = array(); // kind of renderer: array, csv, html, null, text, xml, ... $driverType = 'array'; // case insensitive // Turn Off the silent mode, and display simple wait text messages $driverOptions = array('silent' => false, 'progress' => 'text'); $pci = new PHP_CompatInfo($driverType, $driverOptions); $r = $pci->parseData($datasource, $options); ?> ]]> </programlisting> See also the <filename>docs/examples/parseDir_withCustomProgressBar.php</filename> example in the package distribution, to customize a progress bar for the CLI and pci script usage. </para> </listitem> <listitem> <para> <emphasis role="bold">output-level</emphasis> allow to choose what information (condition code level, extensions, constants, tokens, version) will be shown or hidden. </para> <para> Default value is 31: that means we show all details. See the <link linkend="package.php.php-compatinfo.command-line">Command-Line Parser</link> section, and -o | --output-level switch to learn more about values and corresponding behaviors. </para> </listitem> <listitem> <para> <emphasis role="bold">summarize</emphasis> mode, is usefull when you parse more than one file, and don't want to see intermediate result of each file, but only the final one. </para> <para> Default is turn off. </para> </listitem> <listitem> <para> <emphasis role="bold">verbose</emphasis> level, give details deep you want to have: from 0 (no extra information) to 7 (full details). </para> <para> Default level is 0. See the <link linkend="package.php.php-compatinfo.command-line">Command-Line Parser</link> section, and -v | --verbose switch to learn more about values and corresponding behaviors. </para> </listitem> </itemizedlist> </para> <para> <important> <para> All renderers can be run in both interfaces (web and cli), this is why we can find a hash named <emphasis>args</emphasis> in the driver array options (second parameter of PHP_CompatInfo class constructor). This hash replace corresponding arguments you should have (otherwise) to specify on the Command-Line. </para> </important> </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.array"> <title>Array renderer options</title> <para> Array renderer used two drivers to show dump of results. Default is <literal>PHP</literal> (var_export function). The other one is <literal>PEAR::Var_Dump</literal>. You can use this last one only if package is installed on your system. </para> <para> While there are no specific options for PHP driver, you can use all options of PEAR::Var_Dump to beautify the dump of results. See example <filename>docs/examples/pci180_parsefile.php</filename> in the package distribution. </para> <para> First key of hash (<literal>options</literal>) allow to choose the Var_Dump renderer (display_mode) you want. <caution> <para> Only <emphasis>display_mode = Text</emphasis> is allowed if you run PHP_CompatInfo on CLI. </para> </caution> Second key of hash (<literal>rendererOptions</literal>) allow to give specific options to the Var_Dump renderer identified by display_mode directive. </para> <para> <note> <para> <emphasis role="bold">Var_Dump</emphasis> package exists for two major versions of PHP. </para> <para> <ulink url="http://pear.php.net/package/Var_Dump"> Var_Dump PHP 4 on default PEAR channel </ulink> (branch 1.0) </para> <para> <ulink url="http://toolbox.aldabase.com/index.php?package=Var_Dump"> Var_Dump PHP 5 on PEAR channel Toolbox </ulink> (branch 1.2) </para> </note> </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.csv"> <title>Csv renderer options</title> <para> Csv renderer can be customized only in one way: change delimiters characters </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">fields-values-separated-by</emphasis> identify the delimiter of values when there is a list given (extensions, constants, tokens). Default is <emphasis role="bold">,</emphasis> </para> </listitem> <listitem> <para> <emphasis role="bold">fields-terminated-by</emphasis> identify the delimiter of fields (those given by the output-level directive). Default is <emphasis role="bold">;</emphasis> </para> </listitem> <listitem> <para> <emphasis role="bold">fields-enclosed-by</emphasis> identify the protect field character if content have one or more restrictive character as given by previous options. Default is <emphasis role="bold">"</emphasis> </para> </listitem> <listitem> <para> <emphasis role="bold">lines-terminated-by</emphasis> identify the end-of-line character. Usefull if you want to generate a file for another platform than those who have produced the results. Default is <emphasis role="bold">PHP_EOL constant</emphasis> </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.html"> <title>Html renderer options</title> <para> Html renderer have only one specific option : </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">tdwidth</emphasis> that give size of each column (in em css unit), even if there are not shown (see output-level value). Default is <emphasis role="bold">18,4,2,7,13</emphasis> </para> <para> That means: File is 18 em width, Version is 4 em width, C (cond_code) is 2 em width, Extensions is 7 em width, and Constants/Tokens is 13 em width. </para> </listitem> </itemizedlist> </para> <para> See also the <filename>docs/examples/pci180_parsedir_tohtml.php</filename> example in the package distribution, howto define your own html renderer. </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.text"> <title>Text renderer options</title> <para> Text renderer have only one specific option : </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">colwidth</emphasis> that give size of file (f), extensions (e), and constants/tokens (c) column (in character unit), even if there are not shown (see output-level value). Default is <emphasis role="bold">f = 29, e = 12, c = 20)</emphasis> </para> </listitem> </itemizedlist> </para> <para> See the <link linkend="package.php.php-compatinfo.command-line">Command-Line Parser</link> section, and -t | --tab switch to learn more about optimized values depending of output-level </para> </refsect1> <refsect1 id="package.php.php-compatinfo.renderer.xml"> <title>Xml renderer options</title> <para> Xml renderer have only two specific options : </para> <para> <itemizedlist> <listitem> <para> <emphasis role="bold">use-beautifier</emphasis> tell if we use the PEAR::XML_Beautifier package to beautify XML output. Default is <emphasis role="bold">auto</emphasis> (use only if available) </para> </listitem> <listitem> <para> <emphasis role="bold">beautifier</emphasis> is a hash for the PEAR::XML_Beautifier package options. Default is empty array (use all XML_Beautifier package default options). </para> </listitem> </itemizedlist> </para> <para> <tip> <para> Use <literal>no</literal> value if you have PEAR::XML_Beautifier installed, and you don't want to have XML beautified. </para> </tip> </para> <para> See also the <filename>docs/examples/pci180_parsedata_toxml.php</filename>, and <filename>docs/examples/pci180_parsestring_toxml.php</filename> examples in the package distribution. </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 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 -->