Parser
in package
FinalYes
Determines the correct markup language parser to use based on the input and output format and with it, and parses the file contents.
Table of Contents
Properties
- $documentNameResolver : DocumentNameResolverInterface
- $parserContext : ParserContext|null
- $parserStrategies : array<string|int, MarkupLanguageParser>
Methods
- __construct() : mixed
- parse() : DocumentNode
- prepare() : void
- registerStrategy() : void
- createParserContext() : ParserContext
- determineParser() : MarkupLanguageParser
Properties
$documentNameResolver read-only
private
DocumentNameResolverInterface
$documentNameResolver
$parserContext
private
ParserContext|null
$parserContext
= null
$parserStrategies
private
array<string|int, MarkupLanguageParser>
$parserStrategies
= []
Methods
__construct()
public
__construct(DocumentNameResolverInterface $documentNameResolver, iterable<string|int, MarkupLanguageParser> $parserStrategies) : mixed
Parameters
- $documentNameResolver : DocumentNameResolverInterface
- $parserStrategies : iterable<string|int, MarkupLanguageParser>
parse()
public
parse(string $text[, string $inputFormat = 'rst' ]) : DocumentNode
Parameters
- $text : string
- $inputFormat : string = 'rst'
Return values
DocumentNodeprepare()
public
prepare(FilesystemInterface|null $origin, string $sourcePath, string $fileName, ProjectNode $projectNode[, int $initialHeaderLevel = 1 ]) : void
Parameters
- $origin : FilesystemInterface|null
- $sourcePath : string
- $fileName : string
- $projectNode : ProjectNode
- $initialHeaderLevel : int = 1
Tags
registerStrategy()
public
registerStrategy(MarkupLanguageParser $strategy) : void
Parameters
- $strategy : MarkupLanguageParser
createParserContext()
private
createParserContext(string $sourcePath, string $file, FilesystemInterface $origin, int $initialHeaderLevel, ProjectNode $projectNode) : ParserContext
Parameters
- $sourcePath : string
- $file : string
- $origin : FilesystemInterface
- $initialHeaderLevel : int
- $projectNode : ProjectNode
Return values
ParserContextdetermineParser()
private
determineParser(string $fileExtension) : MarkupLanguageParser
Parameters
- $fileExtension : string