From 16f15ae2b2881c08e11ba09bb2d6ff06afb498af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Tue, 21 Jul 2015 09:49:49 +0200 Subject: [PATCH] Add developer documentation --- daux/Processor.php | 10 +++ docs/00_Getting_Started.md | 28 +++++- .../10_For_Developers/Creating_a_Processor.md | 89 +++++++++++++++++++ 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 daux/Processor.php create mode 100644 docs/10_For_Developers/Creating_a_Processor.md diff --git a/daux/Processor.php b/daux/Processor.php new file mode 100644 index 0000000..da86f9c --- /dev/null +++ b/daux/Processor.php @@ -0,0 +1,10 @@ +dump()); + exit; + } +``` + +also, add this at the beginning of the file: + +```php +use Todaymade\Daux\Tree\Root; +``` + +Let's just try if it works by running `./generate --processor=Processor` + +Yes, you get a big array dump! You're good to go. + +## What can I achieve ? + +There are a few methods that you can override to add some + +### Change the parsed tree. + +By default, Daux.io parses your directory to find pages. but, for a reason or another, you might want to programmatically add some pages. + +This can be done with: + +```php + public function manipulateTree(Root $root) + { + } +``` + +Two helpers from the class `Todaymade\Daux\Tree\Builder` will greatly help you doing that: + +```php + $new = Builder::getOrCreateDir($root, 'New Pages'); + + $page = Builder::getOrCreatePage($new, 'index'); + $page->setContent('The index page for the new folder'); + + $page = Builder::getOrCreatePage($new, 'A New Hope'); + $page->setContent('A long time ago in a galaxy far away'); +``` + +Both methods `getOrCreateDir` and `getOrCreatePage` take two parameters : `parent` and `title` + +### Extend the Markdown Generator + +You can extend the Markdown Parser in any way wou want with this method. + +```php + public function extendCommonMarkEnvironment(Environment $environment) + { + } +``` + +See the details on [CommonMark's website](http://commonmark.thephpleague.com/customization/overview/). + +### Add new generators + +You can add new generators to Daux.io and use them right away, they must implement the +`\Todaymade\Daux\Format\Base\Generator` interface and if you want to use the live mode with your generator +you have to implement `\Todaymade\Daux\Format\Base\LiveGenerator`. + +```php + public function addGenerators() + { + return ['custom_generator' => '\Todaymade\Daux\Extension\MyNewGenerator']; + } +``` +