RestructuredTextFormatter

namespace

bhenk\doc2rst\format

predicates

Cloneable | Instantiable

implements

Stringable

extends

AbstractFormatter

hierarchy

RestructuredTextFormatter -> AbstractFormatter

This RestructuredTextFormatter is handling literal reStructuredText

This formatter is started with 3 tics on a new line, followed by rst. Optionally this is followed by a command followed by zero or more parameters. The block is ended with 3 tics on a new line.

syntax

```rst [command] [...]
.. rst instructions
(...)
```

RestructuredTextFormatter for now only knows one command: replace. This command works similar to the PHP-function str_replace and works on the contents of the block. The replace command takes 2 parameters: search-string, replace-string.

Example

```rst replace & @
.. code-block::

   &param ["Type"] $[name] [<description>]

```

The result:

@param ["Type"] $[name] [<description>]

In the above the tag-name @param can be in a code block of the PHPDoc, without being mangled by your IDE, that thinks you misplaced a tag.

Of course, you can always use rst directly in your PHPDocs:

.. hint:: text of special interest

Result:

Hint

text of special interest


Methods

RestructuredTextFormatter::handleLine

predicates

public

implements

AbstractFormatter::handleLine

@inheritdoc

Handle a line of PHPDoc

As long as the formatter wants more lines it should return true. When it has enough it should return false.

param string $line - line to format
return bool - true if more lines are welcome, false otherwise

@inheritdoc from method AbstractFormatter::handleLine

public function handleLine(
      Parameter #0 [ <required> string $line ]
 ): bool
param string $line - line of a code block
return bool - true as long second and following lines do not start with 3 tics

RestructuredTextFormatter::addLine

predicates

protected

inherited from

AbstractFormatter::addLine

Add a line to the resulting block

protected function addLine(
      Parameter #0 [ <required> Stringable|string $line ]
 ): void
param Stringable | string $line - the line to add
return void

RestructuredTextFormatter::__toString

predicates

public

implements

Stringable::__toString

inherited from

AbstractFormatter::__toString

Returns a reStructuredText representation of the contents of the block

public function __toString(): string
return string - reStructuredText representation of the contents

RestructuredTextFormatter::getLineCount

predicates

protected

inherited from

AbstractFormatter::getLineCount

protected function getLineCount(): int
return int

RestructuredTextFormatter::increaseLineCount

predicates

protected

inherited from

AbstractFormatter::increaseLineCount

protected function increaseLineCount(): int
return int

Fri, 31 Mar 2023 13:22:46 +0000