Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcDocumentRstVisitor

Document::ezcDocumentRstVisitor

Class ezcDocumentRstVisitor

Abstract visitor base for RST documents represented by the parser AST.

Source for this file: /Document/src/document/rst/visitor.php

Implements interfaces:

Version:   //autogen//

Descendants

Child Class Description
ezcDocumentRstXhtmlVisitor HTML visitor for the RST AST.
ezcDocumentRstDocbookVisitor Docbook visitor for the RST AST.

Constants

DUBLICATE = 4 Duplicate reference target. Will throw an error on use.
UNUSED = 1 Unused reference target
USED = 2 Used reference target

Member Variables

protected int $anonymousReferenceCounter = 0
Index of last requested anonymous reference target.
protected array $anonymousReferences = array()
Collected anonymous externals reference targets
protected ezcDocumentRstDocumentNode $ast
Reference to the AST root node.
protected array $errors = array()
Aggregated minor errors during document processing.
protected array $footnoteCounter = array( 0 )
Label dependant foot note counters for footnote auto enumeration.
protected array $footnotes = array()
List with footnotes for later rendering.
protected array $footnoteSymbols = array(
"*",
"\xE2\x80\xA0",
"\xE2\x80\xA1",
"\xC2\xA7",
"\xC2\xB6",
"#",
"\xE2\x99\xA0",
"\xE2\x99\xA5",
"\xE2\x99\xA6",
"\xE2\x99\xA3",
)

Foot note symbol signs, as defined at http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#auto-symbol-footnotes
protected array $namedExternalReferences = array()
Collected named external reference targets
protected string $path
Location of the currently processed RST file, relevant for inclusion.
protected array $referenceCounter = array()
Counter of duplicate references for duplicate references.
protected array $references = array()
Collected refrence targets.
protected ezcDocumentRst $rst
RST document handler
protected array $substitutions = array()
Collected substitutions.
protected array $usedIDs = array()
Array of already generated IDs, so none will be used twice.

Method Summary

public void __construct( $document , $path )
Create visitor from RST document handler.
protected void addFootnote( $node )
Add footnote
protected void aggregateListItems( $node )
Aggregate list items
protected string calculateId( $string )
Get a valid identifier string
protected string calculateUniqueId( $string )
Calculate unique ID
protected bool compareListType( $item , $lastItem )
Compare two list items
public string getAnonymousReferenceTarget( )
Get anonymous reference target
public array getErrors( )
Return list of errors occured during visiting the document.
public string getNamedExternalReference( $name )
Return named external reference target
public ezcDocumentRstFootnoteNode hasFootnoteTarget( $string , $node )
Check for internal footnote reference target
public string hasReferenceTarget( $string , [ $node = null] , [ $force = false] )
Check for internal reference target
public string nodeToString( $node )
Transform a node tree into a string
protected void preProcessAst( $node )
Pre process AST
protected void substitute( $string )
Get substitution contents
protected string tokenListToString( $tokens )
Get string from token list.
public void triggerError( $level , $message , [ $file = null] , [ $line = null] , [ $position = null] )
Trigger visitor error
public mixed visit( $ast )
Docarate RST AST
protected void visitChildren( $root , $node )
Visit children
protected void visitSubstitutionReference( $root , $node )
Visit substitution reference node
protected void visitText( $root , $node )
Visit text node

Methods

__construct

void __construct( ezcDocumentRst $document , string $path )

Create visitor from RST document handler.

Parameters:
Name Type Description
$document ezcDocumentRst
$path string
Redefined in descendants as:
Method Description
ezcDocumentRstXhtmlVisitor::__construct() Create visitor from RST document handler. 

addFootnote

void addFootnote( ezcDocumentRstNode $node )

Add footnote

Parameters:
Name Type Description
$node ezcDocumentRstNode

aggregateListItems

void aggregateListItems( ezcDocumentRstNode $node )

Aggregate list items

Aggregate list items into lists. In RST there are only list items, which are aggregated to lists depending on their bullet type. The related list items are aggregated into one list.

Parameters:
Name Type Description
$node ezcDocumentRstNode

calculateId

string calculateId( string $string )

Get a valid identifier string

Get a valid identifier string from an arbritrary string.

Parameters:
Name Type Description
$string string

calculateUniqueId

string calculateUniqueId( string $string )

Calculate unique ID

Calculate a valid identifier, which is unique for this document.

Parameters:
Name Type Description
$string string

compareListType

bool compareListType( ezcDocumentRstNode $item , ezcDocumentRstNode $lastItem )

Compare two list items

Check if the given list item may be a successor in the same list, as the last item in the list. Returns the boolean status o the check.

Parameters:
Name Type Description
$item ezcDocumentRstNode
$lastItem ezcDocumentRstNode

getAnonymousReferenceTarget

string getAnonymousReferenceTarget( )

Get anonymous reference target

Get the target URL of an anonomyous reference target.

getErrors

array getErrors( )

Return list of errors occured during visiting the document.

May be an empty array, if on errors occured, or a list of ezcDocumentVisitException objects.

Implementation of:
Method Description
ezcDocumentErrorReporting::getErrors() Return list of errors occured during visiting the document.

getNamedExternalReference

string getNamedExternalReference( string $name )

Return named external reference target

Get the target value of a named external reference.

Parameters:
Name Type Description
$name string

hasFootnoteTarget

ezcDocumentRstFootnoteNode hasFootnoteTarget( string $string , ezcDocumentRstNode $node )

Check for internal footnote reference target

Returns the target name, when an internal reference target exists and sets it to used, and false otherwise.

Parameters:
Name Type Description
$string string
$node ezcDocumentRstNode

hasReferenceTarget

string hasReferenceTarget( string $string , [ezcDocumentRstNode $node = null] , [bool $force = false] )

Check for internal reference target

Returns the target name, when an internal reference target exists and sets it to used, and false otherwise. For duplicate reference targets and missing reference targets an error will be triggered.

An optional third parameter may enforce the fetching of the reference, even if there are duplicates, so that they still can be referenced in some way.

Parameters:
Name Type Description
$string string
$node ezcDocumentRstNode
$force bool

nodeToString

string nodeToString( ezcDocumentRstNode $node )

Transform a node tree into a string

Transform a node tree, with all its subnodes into a string by only getting the textuual contents from ezcDocumentRstTextLineNode objects.

Parameters:
Name Type Description
$node ezcDocumentRstNode

preProcessAst

void preProcessAst( ezcDocumentRstNode $node )

Pre process AST

Performs multiple preprocessing steps on the AST:

Collect all possible reference targets in the AST to know the actual destianation for references while decorating. The references are stored in an internal structure and you may request the actual link by using the getReferenceTarget() method.

Aggregate list items into lists. In RST there are only list items, which are aggregated to lists depending on their bullet type. The related list items are aggregated into one list.

Parameters:
Name Type Description
$node ezcDocumentRstNode

substitute

void substitute( string $string )

Get substitution contents

Parameters:
Name Type Description
$string string

tokenListToString

string tokenListToString( $tokens )

Get string from token list.

Parameters:
Name Type Description
$tokens array

triggerError

void triggerError( int $level , string $message , [string $file = null] , [int $line = null] , [int $position = null] )

Trigger visitor error

Emit a vistitor error, and convert it to an exception depending on the error reporting settings.

Parameters:
Name Type Description
$level int
$message string
$file string
$line int
$position int
Implementation of:
Method Description
ezcDocumentErrorReporting::triggerError() Trigger parser error.

visit

mixed visit( $ast )

Docarate RST AST

Visit the RST abstract syntax tree.

Parameters:
Name Type Description
$ast ezcDocumentRstDocumentNode
Redefined in descendants as:
Method Description
ezcDocumentRstXhtmlVisitor::visit() Docarate RST AST 
ezcDocumentRstXhtmlBodyVisitor::visit() Docarate RST AST 
ezcDocumentRstDocbookVisitor::visit() Docarate RST AST 

visitChildren

void visitChildren( $root , ezcDocumentRstNode $node )

Visit children

Just recurse into node and visit its children, ignoring the actual node.

Parameters:
Name Type Description
$root DOMNode
$node ezcDocumentRstNode
Redefined in descendants as:
Method Description
ezcDocumentRstDocbookVisitor::visitChildren() Visit children 

visitSubstitutionReference

void visitSubstitutionReference( $root , ezcDocumentRstNode $node )

Visit substitution reference node

Parameters:
Name Type Description
$root DOMNode
$node ezcDocumentRstNode
Redefined in descendants as:
Method Description
ezcDocumentRstDocbookVisitor::visitSubstitutionReference() Visit substitution reference node 

visitText

void visitText( $root , ezcDocumentRstNode $node )

Visit text node

Parameters:
Name Type Description
$root DOMNode
$node ezcDocumentRstNode
Redefined in descendants as:
Method Description
ezcDocumentRstDocbookVisitor::visitText() Visit text node 
Documentation generated by phpDocumentor 1.4.3