phpDocumentor / phpDocumentor/guides
Deprecated directive without attributes
@linawolf is already working on this.
Since Sep 2, 2026.
- Dominant language
- PHP
- Stars
- 36
- Forks
- 22
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 24
Description
Directives must contain a Directive attribute and when applicable Option attributes.
#[Directive(name: 'example')]
#[Option(name: 'option1', type: OptionType::Boolean, description: 'An example option', default: false)]
class ExampleSubDirective extends SubDirective
{
public function createNode(\phpDocumentor\Guides\RestructuredText\Nodes\DirectiveNode $directiveNode): Node
{
return new ExampleNode(
$this->readOption($directiveNode, 'option1'),
$directiveNode->getDataNode(),
$this->text,
$directiveNode->getChildren(),
);
}
}
The new way of defining directives allows us to do validation on the options set on the DirectiveNode. But also brings us closer to the options to do validation on the parsed document. Directives migrated to this new setup MUST implement the createNode method, which is responsible for the creation of the final node used during rendering.
Steps to migrate:
- Move the logic to create the node(s) created by the directive into the createNode method.
- Remove the
getNameandgetAliasesmethod and replace them with theDirectiveattribute - Remove the
processSubandprocessmethods
More info
Read more about directive in our docs: https://docs.phpdoc.org/components/guides/guides/developers/directive.html#implement-a-sub-directive
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.