PHP Класс Gregwar\RST\Parser

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$buffer The buffer is an array containing current lines that are parsed
$currentLine Current line
$directive Current directive to be applied on next node
$directives Current directives
$document Current document
$environment Environment
$filename File name
$includeAllowed Allow include directives?
$includeRoot Behaves like PHP's open_basedir
$isCode Is the current node code ?
$lineInfo
$listFlow
$listLine
$specialLetter Current level of special lines (==== and so)
$state Current state

Открытые методы

Метод Описание
__construct ( $environment = null, $kernel = null )
createSpan ( $span ) : Span Create a span, which is a text with inline style
getCurrentLine ( ) Gets the current line
getDocument ( ) : Gregwar\RST\Document Get the current document
getEnvironment ( ) : Environment Get the current environment
getFilename ( ) Gets the current filename
getIncludeAllowed ( ) : boolean
getIncludeRoot ( ) : string
getKernel ( ) : Kernel Get the current kernel
getSubParser ( ) : Parser Get a parser with the same environment that this one
includeFileAllowed ( $path ) : boolean Is this file allowed to be included?
includeFiles ( $document ) Include all files described in $document and returns the new string of the given document with includes processed
initDirectives ( ) Initializing built-in directives
initReferences ( ) Initializing references
parse ( string $document ) : Gregwar\RST\Document Parse a document and return a Document instance
parseFile ( string $file ) : Gregwar\RST\Document Parses a given file and return a Document instance
parseLink ( string $line ) : boolean Try to parse a link definition
parseLocal ( string $document ) : Gregwar\RST\Document
pushListLine ( string $line, boolean $flush = false ) : boolean Push a line to the current list node buffer
registerDirective ( Gregwar\RST\Directive $directive ) Register a new directive handler
setIncludePolicy ( boolean $allow, string $directory = null ) : self Allow/disallow includes, or restrict them to a directory

Защищенные методы

Метод Описание
directiveAddOption ( string $line ) Try to add an option line to the current directive, returns true if sucess and false if failure
findTableChars ( string $line ) : array | boolean Finding the table chars
flush ( ) Flushes the current buffer to create a node
getCurrentDirective ( ) : Gregwar\RST\Directive Gets the current directive
init ( )
initDirective ( string $line ) : false Get current directive if the buffer contains one
isBlockLine ( string $line ) : boolean A line is a code line if it's empty or if it begins with a trimable caracter, for instance:
isComment ( string $line ) : boolean Is this line a comment ?
isDirective ( string $line ) : boolean Is this line a directive ?
isListLine ( string $line ) : boolean Is the given line a list line ?
isSpecialLine ( string $line ) : boolean Tell if a line is a special separating line for title and separators, returns the depth of the special line
parseLine ( string &$line ) Process one line
parseLines ( string $document ) Process all the lines of a document string
parseListLine ( string $line ) : array Parses a list line
parseTableLine ( string $line ) : mixed If the given line is a table line, this will returns the parts of the given line, i.e the offset of the separators
prepareCode ( ) : boolean Tells if the current buffer is announcing a block of code

Описание методов

__construct() публичный Метод

public __construct ( $environment = null, $kernel = null )

createSpan() публичный Метод

Create a span, which is a text with inline style
public createSpan ( $span ) : Span
$span the content string
Результат Span a span object

directiveAddOption() защищенный Метод

Try to add an option line to the current directive, returns true if sucess and false if failure
protected directiveAddOption ( string $line )
$line string

findTableChars() защищенный Метод

Finding the table chars
protected findTableChars ( string $line ) : array | boolean
$line string
Результат array | boolean

flush() защищенный Метод

Flushes the current buffer to create a node
protected flush ( )

getCurrentDirective() защищенный Метод

Gets the current directive
protected getCurrentDirective ( ) : Gregwar\RST\Directive
Результат Gregwar\RST\Directive

getCurrentLine() публичный Метод

Gets the current line
public getCurrentLine ( )

getDocument() публичный Метод

Get the current document
public getDocument ( ) : Gregwar\RST\Document
Результат Gregwar\RST\Document the document

getEnvironment() публичный Метод

Get the current environment
public getEnvironment ( ) : Environment
Результат Environment the parser environment

getFilename() публичный Метод

Gets the current filename
public getFilename ( )

getIncludeAllowed() публичный Метод

public getIncludeAllowed ( ) : boolean
Результат boolean

getIncludeRoot() публичный Метод

public getIncludeRoot ( ) : string
Результат string

getKernel() публичный Метод

Get the current kernel
public getKernel ( ) : Kernel
Результат Kernel the kernel

getSubParser() публичный Метод

Get a parser with the same environment that this one
public getSubParser ( ) : Parser
Результат Parser a new parser with the same environment

includeFileAllowed() публичный Метод

Is this file allowed to be included?
public includeFileAllowed ( $path ) : boolean
$path
Результат boolean

includeFiles() публичный Метод

Include all files described in $document and returns the new string of the given document with includes processed
public includeFiles ( $document )

init() защищенный Метод

protected init ( )

initDirective() защищенный Метод

.. |variable| name:: data :option: value :otherOption: otherValue
protected initDirective ( string $line ) : false
$line string
Результат false if this is not a directive, else an array containing : - variable: the variable name of the directive - name: the directive name - data: the data of the directive - options: an array of all the options and their values

initDirectives() публичный Метод

Initializing built-in directives
public initDirectives ( )

initReferences() публичный Метод

Initializing references
public initReferences ( )

isBlockLine() защищенный Метод

This is a block because there is a space in the front of the caracters This is still part of the block, even if there is an empty line
protected isBlockLine ( string $line ) : boolean
$line string the line text
Результат boolean true if the line is still in a block

isComment() защищенный Метод

Is this line a comment ?
protected isComment ( string $line ) : boolean
$line string the line
Результат boolean true if it's a comment

isDirective() защищенный Метод

Is this line a directive ?
protected isDirective ( string $line ) : boolean
$line string the line
Результат boolean true if it's a directive

isListLine() защищенный Метод

Is the given line a list line ?
protected isListLine ( string $line ) : boolean
$line string
Результат boolean true if the given line is a list line

isSpecialLine() защищенный Метод

Tell if a line is a special separating line for title and separators, returns the depth of the special line
protected isSpecialLine ( string $line ) : boolean
$line string
Результат boolean

parse() публичный Метод

Parse a document and return a Document instance
public parse ( string $document ) : Gregwar\RST\Document
$document string The contents (string) of the document
Результат Gregwar\RST\Document The created document

parseFile() публичный Метод

Parses a given file and return a Document instance
public parseFile ( string $file ) : Gregwar\RST\Document
$file string the file name to parse
Результат Gregwar\RST\Document $document the document instance

parseLine() защищенный Метод

Process one line
protected parseLine ( string &$line )
$line string the line string

parseLines() защищенный Метод

Process all the lines of a document string
protected parseLines ( string $document )
$document string the string (content) of the document

parseListLine() защищенный Метод

Parses a list line
protected parseListLine ( string $line ) : array
$line string the string line
Результат array containing: - true if the list is ordered, false else - the depth of the list - the text of the first line without the tick

parseLocal() публичный Метод

public parseLocal ( string $document ) : Gregwar\RST\Document
$document string
Результат Gregwar\RST\Document The created document

parseTableLine() защищенный Метод

====================== ========= =========== 0 23 33 +---------------------+---------+-----------+ 1 23 33
protected parseTableLine ( string $line ) : mixed
$line string
Результат mixed

prepareCode() защищенный Метод

Tells if the current buffer is announcing a block of code
protected prepareCode ( ) : boolean
Результат boolean

pushListLine() публичный Метод

Push a line to the current list node buffer
public pushListLine ( string $line, boolean $flush = false ) : boolean
$line string
$flush boolean
Результат boolean

registerDirective() публичный Метод

Register a new directive handler
public registerDirective ( Gregwar\RST\Directive $directive )
$directive Gregwar\RST\Directive a directive handler

setIncludePolicy() публичный Метод

Allow/disallow includes, or restrict them to a directory
public setIncludePolicy ( boolean $allow, string $directory = null ) : self
$allow boolean
$directory string
Результат self

Описание свойств

$buffer защищенное свойство

The buffer is an array containing current lines that are parsed
protected $buffer

$currentLine защищенное свойство

Current line
protected $currentLine

$directive защищенное свойство

Current directive to be applied on next node
protected $directive

$directives защищенное свойство

Current directives
protected $directives

$document защищенное свойство

Current document
protected $document

$environment защищенное свойство

Environment
protected $environment

$filename защищенное свойство

File name
protected $filename

$includeAllowed защищенное свойство

Allow include directives?
protected $includeAllowed

$includeRoot защищенное свойство

Behaves like PHP's open_basedir
protected $includeRoot

$isCode защищенное свойство

Is the current node code ?
protected $isCode

$lineInfo защищенное свойство

protected $lineInfo

$listFlow защищенное свойство

protected $listFlow

$listLine защищенное свойство

protected $listLine

$specialLetter защищенное свойство

Current level of special lines (==== and so)
protected $specialLetter

$state защищенное свойство

Current state
protected $state