FigureDirective
extends SubDirective
in package
Renders an image, example :
.. figure:: image.jpg :width: 100 :alt: An image
Here is an awesome caption
Attributes
- #[Option]
- $name: 'width'
- $description: 'Width of the image in pixels'
- #[Option]
- $name: 'height'
- $description: 'Height of the image in pixels'
- #[Option]
- $name: 'alt'
- $description: 'Alternative text for the image'
- #[Option]
- $name: 'scale'
- $description: 'Scale of the image, e.g. 0.5 for half size'
- #[Option]
- $name: 'target'
- $description: 'Target for the image, e.g. a link to the image'
- #[Option]
- $name: 'class'
- $description: 'CSS class to apply to the image'
- #[Option]
- $name: 'name'
- $description: 'Name of the image, used for references'
- #[Option]
- $name: 'align'
- $description: 'Alignment of the image, e.g. left, right, center'
Table of Contents
Properties
Methods
- __construct() : mixed
- createNode() : Node|null
- getAliases() : array<string|int, string>
- Allow a directive to be registered under multiple names.
- getName() : string
- Get the directive name
- process() : Node|null
- This is the function called by the parser to process the directive, it can be overloaded to do anything with the document, like tweaking nodes or change the parser context
- processNode() : Node
- This can be overloaded to write a directive that just create one node for the document, which is common
- getStartingRule() : Rule<string|int, CollectionNode>
- optionsToArray() : array<string, scalar|null>
- processSub() : Node
- readAllOptions() : array<string, scalar|array<string|int, scalar>|null>
- readOption() : mixed
- Gets an option value from a directive based on attribute configuration.
Properties
$startingRule
protected
Rule
$startingRule
$documentNameResolver read-only
private
DocumentNameResolverInterface
$documentNameResolver
Methods
__construct()
public
__construct(DocumentNameResolverInterface $documentNameResolver, Rule $startingRule) : mixed
Parameters
- $documentNameResolver : DocumentNameResolverInterface
- $startingRule : Rule
createNode()
public
createNode(DirectiveNode $directiveNode) : Node|null
Parameters
- $directiveNode : DirectiveNode
Return values
Node|nullgetAliases()
Allow a directive to be registered under multiple names.
public
getAliases() : array<string|int, string>
Aliases can be used for directives whose name has been deprecated or allows for multiple spellings.
Return values
array<string|int, string>getName()
Get the directive name
public
getName() : string
Return values
stringprocess()
This is the function called by the parser to process the directive, it can be overloaded to do anything with the document, like tweaking nodes or change the parser context
public
final process(BlockContext $blockContext, Directive $directive) : Node|null
Parameters
- $blockContext : BlockContext
-
the current document context with the content of the directive
- $directive : Directive
-
parsed directive containing options and variable
Return values
Node|nullprocessNode()
This can be overloaded to write a directive that just create one node for the document, which is common
public
processNode(BlockContext $blockContext, Directive $directive) : Node
The arguments are the same that process
Parameters
- $blockContext : BlockContext
- $directive : Directive
Return values
NodegetStartingRule()
protected
getStartingRule() : Rule<string|int, CollectionNode>
Return values
Rule<string|int, CollectionNode>optionsToArray()
protected
optionsToArray(array<string|int, DirectiveOption> $options) : array<string, scalar|null>
Parameters
- $options : array<string|int, DirectiveOption>
Return values
array<string, scalar|null>processSub()
protected
processSub(BlockContext $blockContext, CollectionNode $collectionNode, Directive $directive) : Node
Parameters
- $blockContext : BlockContext
- $collectionNode : CollectionNode
- $directive : Directive
Return values
NodereadAllOptions()
protected
final readAllOptions(Directive $directive) : array<string, scalar|array<string|int, scalar>|null>
Parameters
- $directive : Directive
Return values
array<string, scalar|array<string|int, scalar>|null>readOption()
Gets an option value from a directive based on attribute configuration.
protected
final readOption(Directive $directive, string $optionName) : mixed
Looks up the option in the directive and returns its value converted to the appropriate type based on the Option attribute defined on this directive class. If the option is not present in the directive, returns the default value from the attribute.
Parameters
- $directive : Directive
-
The directive containing the options
- $optionName : string
-
The name of the option to retrieve
Return values
mixed —The option value converted to the appropriate type, or the default value