Documentation

CodeBlock extends Directive
in package

Renders a code block, example:

.. code-block:: php

Tags
link
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-code-block

Table of Contents

finalize()  : void
Called at the end of the parsing to finalize the document (add something or tweak nodes)
getName()  : string
Get the directive name
process()  : void
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 environment
processAction()  : void
This can be overloaded to write a directive that just do an action without changing the nodes of the document
processNode()  : Node
This can be overloaded to write a directive that just create one node for the document, which is common
wantCode()  : bool
Should the following block be passed as a CodeNode?
setStartingLineNumberBasedOnOptions()  : void

Methods

finalize()

Called at the end of the parsing to finalize the document (add something or tweak nodes)

public finalize(DocumentNode $document) : void
Parameters
$document : DocumentNode
Return values
void

getName()

Get the directive name

public getName() : string
Return values
string

process()

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 environment

public process(Parser $parser, Node|null $node, string $variable, string $data, array<string|int, string> $options) : void
Parameters
$parser : Parser

the calling parser

$node : Node|null

the node that follows the directive

$variable : string

the variable name of the directive

$data : string

the data of the directive (following ::)

$options : array<string|int, string>
Return values
void

processAction()

This can be overloaded to write a directive that just do an action without changing the nodes of the document

public processAction(Parser $parser, string $variable, string $data, array<string|int, string> $options) : void

The arguments are the same that process

Parameters
$parser : Parser
$variable : string
$data : string
$options : array<string|int, string>
Return values
void

processNode()

This can be overloaded to write a directive that just create one node for the document, which is common

public processNode(Parser $parser, string $variable, string $data, array<string|int, string> $options) : Node

The arguments are the same that process

Parameters
$parser : Parser
$variable : string
$data : string
$options : array<string|int, string>
Return values
Node

wantCode()

Should the following block be passed as a CodeNode?

public wantCode() : bool
Return values
bool

setStartingLineNumberBasedOnOptions()

private setStartingLineNumberBasedOnOptions(array<string|int, string> $options, CodeNode $node) : void
Parameters
$options : array<string|int, string>
$node : CodeNode
Return values
void

Search results