Class Converter

Description

Base class for all output converters.

The Converter marks the final stage in phpDocumentor. phpDocumentor works in this order:

Parsing => Intermediate Parsing organization => Conversion to output

A Converter takes output from the phpDocumentor_IntermediateParser and converts it to output. With version 1.2, phpDocumentor includes a variety of output converters:

{@ and using walk() or walk_everything (depending on the value of $sort_absolutely_everything) it "walks" over an array of phpDocumentor elements.}}

  • author: Greg Beaver <cellog@php.net>
  • version: $Id: Converter.inc,v 1.39 2007/12/19 02:16:49 ashnazg Exp $
  • abstract:
  • since: 1.0rc1

Located in /PEAR/PhpDocumentor/phpDocumentor/Converter.inc (line 74)


	
			
Direct descendents
Class Description
CHMdefaultConverter Generates files that MS HTML Help Worshop can use to create a MS Windows compiled help file (CHM)
XMLDocBookpeardoc2Converter XML DocBook converter.
XMLDocBookConverter XML DocBook converter.
HTMLSmartyConverter HTML output converter.
HTMLframesConverter HTML output converter.
PDFdefaultConverter PDF output converter.
Variable Summary
Method Summary
Converter Converter (array &$allp, array &$packp, Classes &$classes, ProceduralPages &$procpages, array $po, boolean $pp, boolean $qm, string $targetDir, string $template, string $title)
string AttrToString (string $tag, attribute $attr, [boolean $unmodified = false])
string Bolden (string $para)
string Br (string $para)
void checkState (mixed $state)
void cleanup ()
void Convert (mixed &$element)
void convertClass ( &$element)
void convertConst (parserConst &$element, [ $additions = array()])
void convertDefine (parserDefine &$element, [array $addition = array()])
void ConvertErrorLog ()
void convertFunction (parserFunction &$element, [ $addition = array()])
void convertGlobal (parserGlobal &$element, [array $addition = array()])
void convertInclude (parserInclude &$element, [ $addition = array()])
void convertMethod (parserMethod &$element, [ $additions = array()])
void convertPage (parserPage &$element)
string ConvertTitle (string $tag, array $attr, string $title, string $cdata)
void ConvertTodoList ()
void &convertTutorial (parserTutorial &$element)
void convertVar (parserVar &$element, [ $additions = array()])
void Convert_RIC (README|INSTALL|CHANGELOG $name, string $contents)
void copyFile (string $file, [ $subdir = ''])
void createParentDir (string $dir)
string EncloseList (string $list,  $ordered)
string EncloseParagraph (string $para)
void endClass ()
void endPage ()
string exampleProgramExample (string $example, [boolean $tutorial = false], [ $inlinesourceparse = null], [ $class = null], [ $linenum = null], [ $filesourcepath = null])
void formatIndex ()
void formatLeftIndex ()
void formatPkgIndex ()
string formatTutorialTOC (array $toc)
array getClassesOnPage (parserData &$element)
mixed getClassLink (string $expr, string $package, [ $file = false], [ $text = false])
mixed getConstLink (string $expr, string $class, string $package, [ $file = false], [ $text = false])
string getConverterDir ()
string getCurrentPageLink ()
string getCurrentPageURL (string $pathinfo)
mixed getDefineLink (string $expr, string $package, [ $file = false], [ $text = false])
string getFileSourceName ( $path, string $pathinfo)
string getFileSourcePath (string $base)
array getFormattedConflicts (mixed &$element, string $type)
array getFormattedDescVars (parserVar &$element)
array|false getFormattedMethodImplements (parserMethod &$element)
array|false getFormattedOverrides (parserMethod &$element)
mixed getFunctionLink (string $expr, string $package, [ $file = false], [ $text = false])
mixed getGlobalLink (string $expr, string $package, [ $file = false], [ $text = false])
string getGlobalValue (string $value)
string getId (abstractLink &$link)
string getIncludeValue (string $value, string $ipath)
mixed &getLink (string $expr, [string $package = false], [array $packages = false])
mixed getMethodLink (string $expr, string $class, string $package, [ $file = false], [ $text = false])
mixed getPageLink (string $expr, string $package, [ $path = false], [ $text = false], [ $packages = false])
array getSortedClassTreeFromClass (string $class, string $package, string $subpackage)
string getSourceLink ( $path)
void getState ()
string getTutorialId ( $package,  $subpackage,  $tutorial,  $id)
tutorialLink|string getTutorialLink (string $expr, [string $package = false], [string $subpackage = false], [array $packages = false])
array getTutorialTree (parserTutorial|array $tutorial)
mixed getVarLink (string $expr, string $class, string $package, [ $file = false], [ $text = false])
boolean hasSourceCode (string $path)
false|parserTutorial hasTutorial (pkg|cls|proc $type, tutorial $name, string $package, [string $subpackage = ''])
string highlightDocBlockSource (string $token, string $word, [boolean $preformatted = false])
string highlightSource (integer $token, string $word, [boolean $preformatted = false])
string highlightTutorialSource (string $token, string $word, [boolean $preformatted = false])
string Italicize (string $para)
string Kbdize (string $para)
string ListItem (string $item)
void Output ( $title)
string postProcess ( $text)
array prepareDocBlock (mixed &$element, [array $names = array()], [boolean $nopackage = true])
string PreserveWhiteSpace (string $string)
string ProgramExample (string $example, [boolean $tutorial = false], [ $inlinesourceparse = null], [ $class = null], [ $linenum = null], [ $filesourcepath = null])
string returnLink (string $link, string $text)
string returnSee (abstractLink &$link, [string $eltext = false])
string Sampize (string $para)
void setSourcePaths (string $path)
void setTargetDir (string $dir)
void setTemplateBase (string $base, string $dir)
void setTemplateDir (string $dir)
string sourceLine (integer $linenumber, string $line, [false|string $path = false])
void startHighlight ()
void TranslateEntity (string $name)
string TranslateTag (string $name, string $attr, string $cdata, string $unconvertedcdata)
void TutorialExample (string $example)
string type_adjust (string $typename)
string unmangle (string $sourcecode)
string vardump_tree ( $tree, [ $indent = ''])
string Varize (string $para)
void walk (array &$pages, array &$package_pages)
void walk_everything ()
void writeExample (string $title, string $path, string $source)
void writeFile (string $file, string $data, [boolean $binary = false])
void writeSource (string $filepath, string $source)
void _rmdir (string $directory)
void _setHighlightCache ( $type,  $token)
string _tutorial_path (parserTutorial $pkg, [parserTutorial $subpkg = 0], [parserTutorial $namepkg = 0])
Variables
array $all_packages (line 366)

All packages encountered in parsing

string|false $class = false (line 105)

set to a classname if currently parsing a class, false if not


Redefined in descendants as:
Classes $classes (line 319)

All class information, organized by path, and by package

array $class_contents = array() (line 269)

alphabetical index of all methods and vars in a class by package/subpackage

The class itself has a link under ###main

Smarty $class_data (line 165)

template for the class currently being processed


Redefined in descendants as:
array $class_elements = array() (line 208)

alphabetized index of classes by package

mixed $curfile (line 313)

full path of the current file being converted

parserPage $curpage (line 171)

current procedural page being processed

array $define_elements = array() (line 201)

alphabetized index of defines by package

array $elements = array() (line 187)

alphabetical index of all elements

array $function_elements = array() (line 222)

alphabetized index of functions by package

array $global_elements = array() (line 215)

alphabetized index of global variables by package

boolean $highlightingSource = false (line 325)

Flag used to help converters determine whether to do special source highlighting

array $leftindex = array('classes' => true, 'pages' => true, 'functions' => true, 'defines' => true, 'globals' => true) (line 384)

Controls which of the one-element-only indexes are generated.

Generation of these indexes for large packages is time-consuming. This is an optimization feature. An example of how to use this is in HTMLframesConverter::$leftindex, and in HTMLframesConverter::formatLeftIndex(). These indexes are intended for use as navigational aids through documentation, but can be used for anything by converters.


Redefined in descendants as:
string $outputformat = 'Generic' (line 90)

output format of this converter

in Child converters, this will match the first part of the -o command-line as in -o HTML:frames:default "HTML"


Redefined in descendants as:
string $package = 'default' (line 95)

package name currently being converted

array $packagecategories (line 359)

Packages associated with categories

Used by the XML:DocBook/peardoc2 converter, and available to others, to group many packages into categories

array $package_elements = array() (line 180)

alphabetical index of all elements sorted by package, subpackage, page, and class.

  • var: Format: array(package => array(subpackage => array('page'|'class' => array(path|classname => array(element, element,...)))))
  • uses: Converter::$sort_absolutely_everything - if true, then $package_elements is used, otherwise, the ParserData::$classelements and ParserData::$pageelements variables are used
mixed $package_output (line 141)

set to value of -po commandline

array $package_parents (line 349)

Hierarchy of packages

Every package that contains classes may have parent or child classes in other packages. In other words, this code is legal:

  1.  

In this case, package one is a parent of package two

string $page (line 147)

name of current page being converted


Redefined in descendants as:
array $page_contents = array() (line 238)

alphabetical index of all elements on a page by package/subpackage

The page itself has a link under ###main

Smarty $page_data (line 159)

template for the procedural page currently being processed


Redefined in descendants as:
array $page_elements = array() (line 194)

alphabetized index of procedural pages by package

bool $parseprivate (line 276)

controls processing of elements marked private with @access private

defaults to false. Set with command-line --parseprivate or -pp

string $path (line 153)

path of current page being converted


Redefined in descendants as:
array $pkg_elements = array() (line 229)

alphabetical index of all elements, indexed by package/subpackage

boolean $processSpecialRoots = false (line 81)

This converter knows about the new root tree processing

In order to fix PEAR Bug #6389


Redefined in descendants as:
bool $quietmode (line 283)

controls display of progress information while parsing.

defaults to false. Set to true for cron jobs or other situations where no visual output is necessary

string $smarty_dir = '' (line 301)

Directory that the smarty templates are in


Redefined in descendants as:
mixed $sort_absolutely_everything = false (line 251)

This is used if the content must be passed in the order it should be read, i.e. by package, procedural then classes

This fixes bug 637921, and is used by PDFdefaultConverter

  • usedby: Converter::$package_elements - if true, then $package_elements is used, otherwise, the ParserData::$classelements and ParserData::$pageelements variables are used

Redefined in descendants as:
boolean $sort_page_contents_by_type = false (line 245)

This determines whether the $page_contents array should be sorted by element type as well as alphabetically by name


Redefined in descendants as:
array $sourcePaths = array() (line 372)

A list of files that have had source code generated

string $subpackage = '' (line 100)

subpackage name currently being converted

mixed $targetDir = '' (line 289)

directory that output is sent to. -t command-line sets this.

string $templateDir = '' (line 295)

Directory that the template is in, relative to phpDocumentor root directory

string $templateName = '' (line 308)

Name of the template, from last part of -o

array $template_options (line 399)

Options for each template, parsed from the options.ini file in the template base directory


Redefined in descendants as:
string $title = 'Generated Documentation' (line 392)
array $todoList = array() (line 429)

List of all @todo tags and a link to the element with the @todo

Format: array(package => array(link to element, array(todo parserTag,...)),...)

Methods
Constructor Converter (line 452)

Initialize Converter data structures

Converter Converter (array &$allp, array &$packp, Classes &$classes, ProceduralPages &$procpages, array $po, boolean $pp, boolean $qm, string $targetDir, string $template, string $title)
AttrToString (line 1307)

Convert the attribute of a Tutorial docbook tag's attribute list

to a string based on the template options.ini

string AttrToString (string $tag, attribute $attr, [boolean $unmodified = false])
  • string $tag: tag name
  • attribute $attr: array
  • boolean $unmodified: if true, returns attrname="value"...
Bolden (line 931)

Used to convert the contents of <b> in a docblock

string Bolden (string $para)
  • string $para
Br (line 1001)

Used to convert <br> in a docblock

string Br (string $para)
  • string $para

Redefined in descendants as:
checkState (line 5362)

Compare parserStringWithInlineTags::Convert() cache state to $state

void checkState (mixed $state)
  • mixed $state
cleanup (line 5073)

Finish up parsing/cleanup directories

void cleanup ()
Convert (line 3978)

Convert all elements to output format

This will call ConvertXxx where Xxx is http://www.php.net/ucfirst($element->type). It is expected that a child converter defines a handler for every element type, even if that handler does nothing. phpDocumentor will terminate with an error if a handler doesn't exist.

  • throws: PDERROR_NO_CONVERT_HANDLER
void Convert (mixed &$element)
convertClass (line 4042)

Default Class Handler

Conversion Handlers

All of the convert* handlers set up template variables for the Smarty template. Sets up the class template. {@, getFormattedConflicts, getFormattedInheritedMethods, and getFormattedInheritedVars are called to complete vital template setup.}}

void convertClass ( &$element)
  • &$element

Redefined in descendants as:
convertConst (line 4213)

Converts class constants for template output.

Conversion Handlers

All of the convert* handlers set up template variables for the Smarty template.

This function must be called by a child converter with any extra template variables needed in the parameter $addition

void convertConst (parserConst &$element, [ $additions = array()])

Redefined in descendants as:
convertDefine (line 4330)

Converts defines for template output

Conversion Handlers

All of the convert* handlers set up template variables for the Smarty template. This function must be called by a child converter with any extra template variables needed in the parameter $addition {@, this method also uses utility functions getGlobalValue(), getFormattedConflicts()}}

void convertDefine (parserDefine &$element, [array $addition = array()])
  • parserDefine &$element
  • array $addition: any additional template variables should be in this array

Redefined in descendants as:
ConvertErrorLog (line 2422)

Convert the phpDocumentor parsing/conversion error log

  • abstract:
void ConvertErrorLog ()

Redefined in descendants as:
convertFunction (line 4387)

Converts function for template output

Conversion Handlers

All of the convert* handlers set up template variables for the Smarty template. This function must be called by a child converter with any extra template variables needed in the parameter $addition

void convertFunction (parserFunction &$element, [ $addition = array()])

Redefined in descendants as:
convertGlobal (line 4296)

Converts global variables for template output

Conversion Handlers

All of the convert* handlers set up template variables for the Smarty template. This function must be called by a child converter with any extra template variables needed in the parameter $addition {@, this method also uses utility functions getGlobalValue(), getFormattedConflicts()}}

void convertGlobal (parserGlobal &$element, [array $addition = array()])
  • parserGlobal &$element
  • array $addition: any additional template variables should be in this array

Redefined in descendants as:
convertInclude (line 4359)

Converts includes for template output

Conversion Handlers

All of the convert* handlers set up template variables for the Smarty template. This function must be called by a child converter with any extra template variables needed in the parameter $addition

void convertInclude (parserInclude &$element, [ $addition = array()])

Redefined in descendants as: