home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / HTMLframesConverter.cls < prev    next >
Encoding:
Text File  |  2004-03-24  |  18.9 KB  |  262 lines

  1. <refentry id="{@id}">
  2.  <refnamediv>
  3.   <refname>Writing templates for the HTMLframes Converter</refname>
  4.   <refpurpose>Learn which template variables are available for use in an HTML:frames template</refpurpose>
  5.  </refnamediv>
  6.  <refsynopsisdiv>
  7.   <author>
  8.    Gregory Beaver
  9.    <authorblurb>
  10.     {@link mailto:cellog@sourceforge.com cellog@sourceforge.com}
  11.    </authorblurb>
  12.   </author>
  13.  </refsynopsisdiv>
  14.  {@toc}
  15.  <refsect1 id="{@id intro}">
  16.   <title>HTML:frames:* Introduction</title>
  17.   <para>This documentation deals only with adding a new template to the HTMLframes Converter.  To learn how to use phpDocumentor, read the {@tutorial phpDocumentor/phpDocumentor.pkg}.  To learn how to write a new Converter, read {@tutorial Converters.pkg}</para>
  18.  </refsect1>
  19.  <refsect1 id="{@id overview}">
  20.   <title>Overview</title>
  21.   <para>The HTML:frames converter uses all of the values from the generic Converter (see {@tutorial template.vars.cls}), and adds a few more.</para>
  22.   <para>All templates have the standard smarty template variables available to them, as well as these:
  23.    <unorderedlist>
  24.     <listitem><para><varname>{$subdir }</varname> string - the combination of "../" that will lead to the base output directory, used for linking to other generated documentation.</para></listitem>
  25.     <listitem><para><varname>{$packageindex}</varname> array - a list of all the packages and their index pages in the format array('link' => link to the index page, 'title' => package name)</para></listitem>
  26.    </unorderedlist>
  27.   </para>
  28.  </refsect1>
  29.  <refsect1 id="{@id template}">
  30.   <title>Template Variables</title>
  31.   <refsect2 id="{@id source}">
  32.    <title>Source Code formatting - filesource.tpl</title>
  33.    <para>When source code is generated via the {@tutorial tags.filesource.pkg} tag, the output is passed into these templates variables:</para>
  34.    <para>
  35.     <unorderedlist>
  36.      <listitem><para><varname>{$source}</varname> string - the fully formatted source code, use as is</para></listitem>
  37.      <listitem><para><varname>{$package}</varname> string - the package name of the source file</para></listitem>
  38.      <listitem><para><varname>{$subpackage}</varname> string - the subpackage name of the source file</para></listitem>
  39.      <listitem><para><varname>{$name}</varname> string - the name of the source file file.ext</para></listitem>
  40.      <listitem><para><varname>{$source_loc}</varname> string - the relative path to the file, used for include() statements</para></listitem>
  41.      <listitem><para><varname>{$docs}</varname> string - a link to the documentation for this file</para></listitem>
  42.     </unorderedlist>
  43.    </para>
  44.   </refsect2>
  45.   <refsect2 id="{@id example}">
  46.    <title>Example Code formatting - examplesource.tpl</title>
  47.    <para>When an example file is specified via the {@tutorial tags.example.pkg} tag, the output is passed into these templates variables:</para>
  48.    <para>
  49.     <unorderedlist>
  50.      <listitem><para><varname>{$source}</varname> string - the fully formatted source code, use as is</para></listitem>
  51.      <listitem><para><varname>{$file}</varname> string - the full path to the file</para></listitem>
  52.      <listitem><para><varname>{$title}</varname> string - the title of this example, from the @example tag</para></listitem>
  53.     </unorderedlist>
  54.    </para>
  55.   </refsect2>
  56.   <refsect2 id="{@id left}">
  57.    <title>Left Frame formatting - left_frame.tpl</title>
  58.    <para>The HTML:frames Converter places a table of contents in the left frame.  This table of contents contains links to class trees, alphabetical indexes, tutorials, and elements organized by category (class/procedural code).</para>
  59.    <refsect3 id="{@id basic}">
  60.     <title>Template variables passed to left_frame.tpl</title>
  61.     <para>Each left_frame.tpl consists of one package's documentation.  Basic template variables passed to left_frame.tpl include:</para>
  62.     <para>
  63.      <unorderedlist>
  64.       <listitem><para><varname>{$info}</varname> array - the table of contents, see {@tutorial HTMLframesConverter.cls#template.left.info} for contents</para></listitem>
  65.       <listitem><para><varname>{$package}</varname> string - package this table of contents documents</para></listitem>
  66.       <listitem><para><varname>{$hastutorials}</varname> boolean - true if this package has external tutorials (see {@tutorial tutorials.pkg})</para></listitem>
  67.       <listitem><para><varname>{$hastodos}</varname> boolean - true if there are any {@tutorial tags.todo.pkg} tags in this package</para></listitem>
  68.       <listitem><para><varname>{$todolink}</varname> string - file.html name of the todo list.</para></listitem>
  69.       <listitem><para><varname>{$classtreepage}</varname> string - name of the file containing class trees, minus .html</para></listitem>
  70.       <listitem><para><varname>{$elementindex}</varname> string - name of the file containing the alphabetical index for this package, minus .html</para></listitem>
  71.       <listitem><para><varname>{$packagedoc}</varname> string|false - link to package-level documentation, or false if there is none</para></listitem>
  72.      </unorderedlist>
  73.     </para>
  74.    </refsect3>
  75.    <refsect3 id="{@id info}">
  76.     <title>The {$info} template variable</title>
  77.     <para>The {$info} variable is an array of arrays, each indexed by subpackage.  Even packages with no explicit {@tutorial tags.subpackage.pkg} tags have a subpackage named '' (empty string).  Elements in the main package can be detected using the smarty code:
  78.      <programlisting role="html">{section name=p loop=$info}{if $info[p].subpackage == ''}...</programlisting>
  79.     </para>
  80.     <para>
  81.      The {$info} variable contains these sub-variables (assuming that {section name=p loop=$info} was used):
  82.      <unorderedlist>
  83.       <listitem><para><varname>{$info[p].package}</varname> string - package name</para></listitem>
  84.       <listitem><para><varname>{$info[p].subpackage}</varname> string - subpackage name</para></listitem>
  85.       <listitem><para><varname>{$info[p].packagedoc}</varname> string - link to old format .html-based package-level documentation (deprecated)</para></listitem>
  86.       <listitem><para><varname>{$info[p].packagetutorial}</varname> string - link to new package-level documentation, or subpackage-level documentation for subpackages</para></listitem>
  87.       <listitem><para><varname>{$info[p].packagetutorialnoa}</varname> string - link to new package-level documentation, or subpackage-level documentation for subpackages, without enclosing <a href="link to docs"> HTML tag.  Use this to do special link handling (opening a new window, opening in the _right frame, etc.)</para></listitem>
  88.       <listitem><para><varname>{$info[p].packagetutorialtitle}</varname> string - title of package-level documentation</para></listitem>
  89.       <listitem><para><varname>{$info[p].files}</varname>/<varname>{$info[p].classes}</varname>/<varname>{$info[p].functions}</varname> array - links to documentation array('link' => html link, 'title' => name of element)</para></listitem>
  90.       <listitem><para><varname>{$info[p].tutorials}</varname> string - Formatted tutorial table of contents, see {@tutorial HTMLframesConverter.cls#template.left.tutorial}</para></listitem>
  91.      </unorderedlist>
  92.     </para>
  93.    </refsect3>
  94.    <refsect3 id="{@id tutorial}">
  95.     <title>Tutorial table of contents formatting - tutorial_tree.tpl</title>
  96.     <para>The tutorial table of contents is formatted using the recursive tutorial_tree.tpl template.  This template has only a few variables:
  97.      <unorderedlist>
  98.       <listitem><para><varname>{$name}</varname> string - abstract name of the tutorial (tutorial.pkg becomes tutorialpkg)</para></listitem>
  99.       <listitem><para><varname>{$parent}</varname> string|false - {$name} from parent tutorial, or false if no parent tutorial</para></listitem>
  100.       <listitem><para><varname>{$main.title}</varname> string - the title of the tutorial.  Use as {main.title|striptags}</para></listitem>
  101.       <listitem><para><varname>{$main.link}</varname> string - link to the tutorial's documentation</para></listitem>
  102.       <listitem><para><varname>{$haskids}</varname> boolean - true if this tutorial has sub-tutorials</para></listitem>
  103.       <listitem><para><varname>{$kids}</varname> string - fully formatted list of child tutorials</para></listitem>
  104.       <listitem><para><varname>{$subtree}</varname> boolean - true if this is a sub-tutorial tree.  Use to modify formatting for sub-tutorial listings.</para></listitem>
  105.      </unorderedlist>
  106.     </para>
  107.     <para>The tutorial_tree.tpl file should represent the hierarchy of tutorials through some form of a nested html tag, such as a nested list (like the default converter), or a nested DHTML menu (like the phpedit or earthli templates).</para>
  108.    </refsect3>
  109.   </refsect2>
  110.   <refsect2 id="{@id classtrees}">
  111.    <title>Class trees - classtrees.tpl</title>
  112.    <para>Class trees are a visual representation of Class inheritance to help facilitate understanding of how a project is organized.  Class trees have only a few template variables:
  113.     <unorderedlist>
  114.      <listitem><para><varname>{$package}</varname> string - the package that base classes are found in</para></listitem>
  115.      <listitem><para><varname>{$classtrees}</varname> array - a pre-formatted list of class trees, organized by base class.  Format is: array('class' => name of class, 'classtree' => fully formatted class tree)</para></listitem>
  116.     </unorderedlist>
  117.    </para>
  118.   </refsect2>
  119.   <refsect2 id="{@id top}">
  120.    <title>Package index - top_frame.tpl</title>
  121.    <para>
  122.     The top frame is used to display links to the highest level of documentation, the package table of contents, and the project-wide README/CHANGELOG/FAQ/NEWS/INSTALL files.
  123.     <unorderedlist>
  124.      <listitem><para><varname>{$packages}</varname> array - A listing of all packages documented, in format array('link' => name of the left_frame.tpl-generated package table of contents, 'title' => name of the package)</para></listitem>
  125.      <listitem><para><varname>{$ric}</varname> array - all of the README/INSTALL/FAQ/NEWS/CHANGELOG files found, in format array('file' => name of the generated output, 'name' => displayable name of the parsed file)</para></listitem>
  126.     </unorderedlist>
  127.    </para>
  128.   </refsect2>
  129.   <refsect2 id="{@id indexes}">
  130.    <title>Alphabetical Indexes - elementindex.tpl/pkgelementindex.tpl</title>
  131.    <para>phpDocumentor's generated alphabetical element indexes are organized into an index of all elements in all packages (elementindex.tpl), and indexes of the elements in each individual package (pkgelementindex.tpl).  Their variables are the same, except for the addition of the <varname>{$package}</varname> variable in pkgelementindex.tpl.  Here are the template variables:</para>
  132.    <para>
  133.     <unorderedlist>
  134.      <listitem><para><varname>{$index}</varname> array - the index items, see {@tutorial HTMLframesConverter.cls#template.indexes.index}</para></listitem>
  135.      <listitem><para><varname>{$letters}</varname> array - a listing of each letter heading that should be used in the index</para></listitem>
  136.     </unorderedlist>
  137.    </para>
  138.    <refsect3 id="{@id index}">
  139.     <title>{$index} contents</title>
  140.     <para>The {$index} variable is an array of index listings organized by their first letter.  All documented elements whose name begins with the letter A will be grouped into the sub-array 'a' => array(listing,listing,...).  The listing is organized as follows:</para>
  141.     <para>
  142.      <unorderedlist>
  143.       <listitem><para><varname>{$index[xxx].name}</varname> string - name of the documented element</para></listitem>
  144.       <listitem><para><varname>{$index[xxx].title}</varname> string - One of Variable, Global, Method, Function, Constant, Page, Include</para></listitem>
  145.       <listitem><para><varname>{$index[xxx].link}</varname> string - hyperlink to the element's documentation, or the file included for include statements</para></listitem>
  146.       <listitem><para><varname>{$index[xxx].listing}</varname> string - A fully-formatted index listing in English.</para></listitem>
  147.      </unorderedlist>
  148.     </para>
  149.    </refsect3>
  150.   </refsect2>
  151.   <refsect2 id="{@id miscellaneous}">
  152.    <title>Miscellaneous Templates - ric.tpl/todolist.tpl/errors.tpl</title>
  153.    <para>These specialized templates will only be used in certain cases.
  154.     <unorderedlist>
  155.      <listitem><para>ric.tpl - This template is only used when files such as README, INSTALL, or CHANGELOG are detected in the base parse directory.</para></listitem>
  156.      <listitem><para>todolist.tpl - This template is only used when a {@tutorial tags.todo.pkg} tag is used in documentation</para></listitem>
  157.      <listitem><para>errors.tpl - This template is always generated, but only contains content when there are parsing syntax errors or logical conflicts in the parsed documentation</para></listitem>
  158.     </unorderedlist>
  159.    </para>
  160.    <refsect3 id="{@id ric}">
  161.     <title>ric.tpl - README/INSTALL/CHANGELOG display</title>
  162.     <para>This is a very simple template.</para>
  163.     <para>
  164.      <unorderedlist>
  165.       <listitem><para><varname>{$name}</varname> string - name of the file (README, for example)</para></listitem>
  166.       <listitem><para><varname>{$contents}</varname> string - contents of the file, ready for display (no modification needed)</para></listitem>
  167.      </unorderedlist>
  168.     </para>
  169.    </refsect3>
  170.    <refsect3 id="{@id todolist}">
  171.     <title>todolist.tpl - listings of @todo tags</title>
  172.     <para>This is also a very simple template, and requires only a {section} tag to process the input.</para>
  173.     <para>
  174.      <unorderedlist>
  175.       <listitem><para><varname>{$todos}</varname> array - Format: array(packagename => array('link' => string element containing @todo tag, 'todos' => array(todo item 1, todo item 2,...)),...)</para></listitem>
  176.      </unorderedlist>
  177.     </para>
  178.    </refsect3>
  179.    <refsect3 id="{@id errors}">
  180.     <title>errors.tpl - phpDocumentor parsing/conversion warnings and errors</title>
  181.     <para>This file is a tool used to help find mistakes in your own documentation, and greatly simplifies determining whether there is a bug in your documentation or in phpDocumentor itself.</para>
  182.     <para>The structure of the errors array passed to errors.tpl is somewhat complex to learn, but easy to use once learned.  Every error or warning is grouped by the file that triggered it.  In the case of post-parsing errors, they are grouped into the pseudo-file "Post-parsing".  Within each file, warnings are grouped separately from errors.  Hence, the structure looks something like:
  183.      <programlisting role="php">
  184.      <![CDATA[
  185. array('Post-parsing' => array('warnings' => array(
  186.                            array('name' => name of warning,
  187.                                  'listing' => description of warning),...
  188.                                       )
  189.                               'errors' => array(
  190.                            array('name' => name of error,
  191.                                  'listing' => description of error),...
  192.                                       )
  193.                        ),
  194.       'file1.php' => array(same structure as 'Post-parsing'),...
  195.      );
  196.     ]]>
  197.      </programlisting>
  198.     </para>
  199.     <para>
  200.      <unorderedlist>
  201.       <listitem><para><varname>{$all}</varname> array - This is the structure listed above</para></listitem>
  202.       <listitem><para><varname>{$files}</varname> array - a listing of all the files, useful for making a table of contents</para></listitem>
  203.       <listitem><para><varname>{$title}</varname> string - this is hard-coded in English.  Override by simple using {assign var="title" value="whatever you want"} before including header.tpl</para></listitem>
  204.      </unorderedlist>
  205.     </para>
  206.    </refsect3>
  207.   </refsect2>
  208.   <refsect2 id="{@id elements}">
  209.    <title>PHP element templates - differences from Standard Converter</title>
  210.    <para>For the basic PHP elements, define, include, function, global variable, class, and so on (see {@tutorial elements.pkg}), there are very few differences between the templates packaged with the HTMLframesConverter and the basic Converter.</para>
  211.    <refsect3 id="{@id var}">
  212.     <title>Class variables - var.tpl</title>
  213.     <para>The only additional variable is:
  214.      <unorderedlist>
  215.       <listitem><para><varname>{$var_dest}</varname> string - html anchor used to pinpoint this class variable's documentation in the class file's documentation.  Use as in: <programlisting role="html"><![CDATA[<a name="#{$var_dest}"></a>]]></programlisting></para></listitem>
  216.      </unorderedlist>
  217.     </para>
  218.    </refsect3>
  219.    <refsect3 id="{@id var}">
  220.     <title>Class methods - method.tpl</title>
  221.     <para>The only additional variable is:
  222.      <unorderedlist>
  223.       <listitem><para><varname>{$method_dest}</varname> string - html anchor used to pinpoint this class method's documentation in the class file's documentation.  Use as in: <programlisting role="html"><![CDATA[<a name="#{$method_dest}"></a>]]></programlisting></para></listitem>
  224.      </unorderedlist>
  225.     </para>
  226.    </refsect3>
  227.    <refsect3 id="{@id var}">
  228.     <title>Functions - function.tpl</title>
  229.     <para>The only additional variable is:
  230.      <unorderedlist>
  231.       <listitem><para><varname>{$function_dest}</varname> string - html anchor used to pinpoint this function's documentation in the procedural file's documentation.  Use as in: <programlisting role="html"><![CDATA[<a name="#{$function_dest}"></a>]]></programlisting></para></listitem>
  232.      </unorderedlist>
  233.     </para>
  234.    </refsect3>
  235.    <refsect3 id="{@id define}">
  236.     <title>Defines - define.tpl</title>
  237.     <para>The only additional variable is:
  238.      <unorderedlist>
  239.       <listitem><para><varname>{$define_link}</varname> string - html anchor used to pinpoint this define statement's documentation in the procedural file's documentation.  Use as in: <programlisting role="html"><![CDATA[<a name="#{$define_link}"></a>]]></programlisting></para></listitem>
  240.      </unorderedlist>
  241.     </para>
  242.    </refsect3>
  243.    <refsect3 id="{@id global}">
  244.     <title>Global Variables - global.tpl</title>
  245.     <para>The only additional variable is:
  246.      <unorderedlist>
  247.       <listitem><para><varname>{$global_link}</varname> string - html anchor used to pinpoint this global variable's documentation in the procedural file's documentation.  Use as in: <programlisting role="html"><![CDATA[<a name="#{$global_link}"></a>]]></programlisting></para></listitem>
  248.      </unorderedlist>
  249.     </para>
  250.    </refsect3>
  251.    <refsect3 id="{@id include}">
  252.     <title>Include Statements - include.tpl</title>
  253.     <para>The only additional variable is:
  254.      <unorderedlist>
  255.       <listitem><para><varname>{$include_file}</varname> string - html anchor used to pinpoint this include statement's documentation in the procedural file's documentation.  Use as in: <programlisting role="html"><![CDATA[<a name="#{$include_file}"></a>]]></programlisting></para></listitem>
  256.      </unorderedlist>
  257.     </para>
  258.    </refsect3>
  259.   </refsect2>
  260.  </refsect1>
  261. </refentry>
  262.