hoaproject / Kitab

Kitab is the ideal companion for Documentation-Driven Quality: Render and Test your documentation.
https://hywan.github.io/Kitab/
79 stars 7 forks source link

feat(target) DocTest can have custom handlers #26

Closed Hywan closed 7 years ago

Hywan commented 7 years ago

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:

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.