\phpDocumentor\Plugin\Scrybe\Converter\RestructuredText\VisitorsDiscover

A specialized RestructuredText Parser/Visitor to aid in the discovery phase.

This class collects all headings and their titles and populates the TableOfContents collection.

Summary

Methods
Properties
Constants
getTableOfContents()
getFilename()
getFilenameWithoutExtension()
getDocument()
visit()
addFileToLastHeading()
No public properties found
No constants found
visitSection()
$rst
$entry_pointers
$last_heading
N/A
No private methods found
No private properties found
N/A

Properties

$entry_pointers

$entry_pointers : array<mixed,\phpDocumentor\Plugin\Scrybe\Converter\Metadata\TableOfContents\Heading>

This array is meant as a cache of the last entry per depth.

To build a hierarchy from a non-recursive method, such as visitSection(), you need a way to reference the last Entry per depth.

By keeping track of these pointers you know onto which parent you will need to add a node by checking which of higher depth was parsed last.

Important: because it is possible that levels are 'skipped' we will need to unset all 'deeper' depths when setting a new one. Otherwise we might inadvertently add an entry to the wrong tree.

Type

array<mixed,\phpDocumentor\Plugin\Scrybe\Converter\Metadata\TableOfContents\Heading>

$last_heading

$last_heading : \phpDocumentor\Plugin\Scrybe\Converter\Metadata\TableOfContents\Heading

This is a pointer to the last discovered heading.

Directives and roles may 'include' Files as children of the currently parsed heading. Elements as the toctree directive or a plain include are examples of such.

Type

\phpDocumentor\Plugin\Scrybe\Converter\Metadata\TableOfContents\Heading

Methods

getTableOfContents()

getTableOfContents() 

Returns the table of contents.

return TableOfContents $toc

getFilename()

getFilename() : string

Returns the filename for this visitor.

Returns

string

getFilenameWithoutExtension()

getFilenameWithoutExtension() : string

Returns the filename for this visitor without an extension.

Returns

string

visit()

visit(\ezcDocumentRstDocumentNode  $ast) 

Parameters

\ezcDocumentRstDocumentNode $ast

addFileToLastHeading()

addFileToLastHeading(\phpDocumentor\Plugin\Scrybe\Converter\Metadata\TableOfContents\File  $file) 

Adds a TableOfContents File object to the last heading that was discovered.

This may be used by roles or directives to insert an include file into the TableOfContents and thus all its headings.

This method is explicitly bound to File objects and not other BaseEntry descendents because inline elements such as headings should also modify the internal pointers for this visitor.

Parameters

\phpDocumentor\Plugin\Scrybe\Converter\Metadata\TableOfContents\File $file

visitSection()

visitSection(\DOMNode  $root, \ezcDocumentRstNode  $node) : void

Visitor for the section heading used to populate the TableOfContents.

This method interprets the heading and its containing text and adds new entries to the TableOfContents object in the RestructuredText document.

Parameters

\DOMNode $root
\ezcDocumentRstNode $node