A code block in the documentation is written with the code block syntax
in CommonMark (3 backticks). A code block can have a type, like php:
```php
// PHP code
```
So far, Kitab was only able to handle php code block type (if no type,
it was assumed to be php too).
This patch introduces a Code Block Handler API. A code block handler is
a class of type
Kitab\Compiler\Target\DocTest\CodeBlockHandler\Definition with 3
methods:
getDefinitionName to get the handler name (e.g. 'php'),
mightHandleCodeBlock to check if the handler can handle a specific
code block,
compileToTestCaseBody to compile the code block content into a
test case body (still written with the atoum API).
The Php code block handler has been implemented. More handlers can be
implemented in the future, like http or pgsql: Kitab will be able to
test examples written in different languages in your PHP documentation.
A code block in the documentation is written with the code block syntax in CommonMark (3 backticks). A code block can have a type, like
php
:So far, Kitab was only able to handle
php
code block type (if no type, it was assumed to bephp
too).This patch introduces a Code Block Handler API. A code block handler is a class of type
Kitab\Compiler\Target\DocTest\CodeBlockHandler\Definition
with 3 methods:getDefinitionName
to get the handler name (e.g.'php'
),mightHandleCodeBlock
to check if the handler can handle a specific code block,compileToTestCaseBody
to compile the code block content into a test case body (still written with the atoum API).The
Php
code block handler has been implemented. More handlers can be implemented in the future, likehttp
orpgsql
: Kitab will be able to test examples written in different languages in your PHP documentation.