phpDocumentor / phpDocumentor/guides

Deprecated directive without attributes

Open
#1,373 0 comments 0 reactions 1 assignee View on GitHub

@linawolf is already working on this.

Since Sep 2, 2026.

deprecation
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 getName and getAliases method and replace them with the Directive attribute
  • Remove the processSub and process methods

More info

Read more about directive in our docs: https://docs.phpdoc.org/components/guides/guides/developers/directive.html#implement-a-sub-directive

See: https://github.com/phpDocumentor/guides/pull/1231

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.