Extension

Extends \Twig_Extension Implements \phpDocumentor\Plugin\Twig\ExtensionInterface

Basic extension adding phpDocumentor specific functionality for Twig templates.

Global variables:

  • ast_node, the current $data element

Functions:

  • path(string) , converts the given relative path to be based of the projects root instead of the current directory

Filters:

  • markdown, converts the associated text from Markdown formatting to HTML.
  • trans, translates the given string
  • route, attempts to generate a URL for a given Descriptor
  • sort_desc, sorts the given objects by their Name property/getter in a descending fashion
  • sort_asc, sorts the given objects by their Name property/getter in a ascending fashion
package

Default

Methods

Registers the structure and transformation with this extension.

__construct(\phpDocumentor\Descriptor\ProjectDescriptor $project, \phpDocumentor\Transformer\Transformation $transformation) 

The Structure and Transformation object can be used to get context from and to provide additional information.

Arguments

$project

\phpDocumentor\Descriptor\ProjectDescriptor

Represents the complete Abstract Syntax Tree.

$transformation

\phpDocumentor\Transformer\Transformation

Represents the transformation meta data used in the current generation cycle.

Converts the given path to be relative to the root of the documentation target directory.

convertToRootPath(string $relative_path) : string

It is not possible to use absolute paths in documentation templates since they may be used locally, or in a subfolder. As such we need to calculate the number of levels to go up from the current document's directory and then append the given path.

For example:

Suppose you are in <root>/classes/my/class.html and you want open
<root>/my/index.html then you provide 'my/index.html' to this method
and it will convert it into ../../my/index.html (<root>/classes/my is
two nesting levels until the root).

This method does not try to normalize or optimize the paths in order to save on development time and performance, and because it adds no real value.

Arguments

$relative_path

string

Response

string

Returns the target directory relative to the Project's Root.

getDestination() : string

Response

string

Returns a list of all filters that are exposed by this extension.

getFilters() : array<mixed,\Twig_SimpleFilter>

Response

array<mixed,\Twig_SimpleFilter>

Returns a listing of all functions that this extension adds.

getFunctions() : array<mixed,\Twig_FunctionInterface>

This method is automatically used by Twig upon registering this extension (which is done automatically by phpDocumentor) to determine an additional list of functions.

See the Class' DocBlock for a listing of functionality added by this Extension.

Response

array<mixed,\Twig_FunctionInterface>

Returns an array of global variables to inject into a Twig template.

getGlobals() : array<mixed,mixed>

Response

array<mixed,mixed>

Returns the name of this extension.

getName() : string

Response

string

The extension name

Sets the destination directory relative to the Project's Root.

setDestination(string $destination) : void

The destination is the target directory containing the resulting file. This destination is relative to the Project's root and can be used for the calculation of nesting depths, etc.

see \phpDocumentor\Plugin\Twig\phpDocumentor\Plugin\Twig\Transformer\Writer\Twig

for the invocation of this method.

Arguments

$destination

string

Sets the router used to render the URL where a Descriptor can be found.

setRouters(\phpDocumentor\Transformer\Router\Queue $routers) : void

Sets the translation component.

setTranslator(\phpDocumentor\Translator\Translator $translator) : void

Arguments

Properties

data

data : \phpDocumentor\Descriptor\ProjectDescriptor

translator

translator : \phpDocumentor\Translator\Translator

routeRenderer

routeRenderer : \phpDocumentor\Transformer\Router\Renderer