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(
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
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
Add footnote
Parameters:
Name | Type | Description |
---|---|---|
$node |
ezcDocumentRstNode |
aggregateListItems
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
Get a valid identifier string
Get a valid identifier string from an arbritrary string.
Parameters:
Name | Type | Description |
---|---|---|
$string |
string |
calculateUniqueId
Calculate unique ID
Calculate a valid identifier, which is unique for this document.
Parameters:
Name | Type | Description |
---|---|---|
$string |
string |
compareListType
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
Get anonymous reference target
Get the target URL of an anonomyous reference target.
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
Return named external reference target
Get the target value of a named external reference.
Parameters:
Name | Type | Description |
---|---|---|
$name |
string |
hasFootnoteTarget
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
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
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
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
Get substitution contents
Parameters:
Name | Type | Description |
---|---|---|
$string |
string |
tokenListToString
Get string from token list.
Parameters:
Name | Type | Description |
---|---|---|
$tokens |
array |
triggerError
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
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
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
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
Visit text node
Parameters:
Name | Type | Description |
---|---|---|
$root |
DOMNode | |
$node |
ezcDocumentRstNode |
Redefined in descendants as:
Method | Description |
---|---|
ezcDocumentRstDocbookVisitor::visitText() |
Visit text node |