Add a more advanced processor system

Cette révision appartient à :
Stéphane Goetz 2015-07-17 18:34:00 +02:00 révisé par Stéphane Goetz
Parent 8dd3c1d6f8
révision e7afd9aa28
7 fichiers modifiés avec 95 ajouts et 11 suppressions

Voir le fichier

@ -20,6 +20,9 @@
"symfony/finder": "~2.7"
},
"autoload": {
"psr-4": {"Todaymade\\Daux\\": "libs/"}
"psr-4": {
"Todaymade\\Daux\\Extension\\": "daux/",
"Todaymade\\Daux\\": "libs/"
}
}
}

BIN
daux.phar

Fichier binaire non affiché.

Voir le fichier

@ -66,13 +66,7 @@ class Compiler
}
// Composer autoload
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/autoload.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_classmap.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_files.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_namespaces.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_psr4.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_real.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/ClassLoader.php'));
$this->addComposer($phar);
$this->addBinary($phar);
// Stubs
@ -99,6 +93,20 @@ class Compiler
$phar->addFromString($path, $content);
}
private function addComposer($phar)
{
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/autoload.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_classmap.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_files.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_namespaces.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_real.php'));
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/ClassLoader.php'));
$content = file_get_contents(__DIR__ . '/../vendor/composer/autoload_psr4.php');
$content = str_replace('$baseDir . \'/daux\'', 'PHAR_DIR . \'/daux\'', $content);
$phar->addFromString('vendor/composer/autoload_psr4.php', $content);
}
private function addBinary($phar)
{
$content = file_get_contents(__DIR__ . '/../generate.php');

Voir le fichier

@ -1,5 +1,6 @@
<?php namespace Todaymade\Daux;
use Symfony\Component\Console\Output\NullOutput;
use Todaymade\Daux\Tree\Builder;
class Daux
@ -12,6 +13,11 @@ class Daux
public $internal_base;
private $docs_path;
/**
* @var Processor
*/
protected $processor;
/**
* @var Tree\Entry
*/
@ -152,4 +158,24 @@ class Daux
return $this->options;
}
/**
* @return Processor
*/
public function getProcessor()
{
if (!$this->processor) {
$this->processor = new Processor($this, new NullOutput(), 0);
}
return $this->processor;
}
/**
* @param Processor $processor
*/
public function setProcessor(Processor $processor)
{
$this->processor = $processor;
}
}

Voir le fichier

@ -18,6 +18,9 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
$this->extendEnvironment($environment);
//TODO :: finish
//$daux->getProcessor()->extendCommonMarkEnvironment($environment);
$this->docParser = new DocParser($environment);
$this->htmlRenderer = new HtmlRenderer($environment);
}

Voir le fichier

@ -33,11 +33,17 @@ class Command extends SymfonyCommand
$processor = $input->getOption('processor');
if (!empty($processor) && $processor != 'none') {
if (file_exists($processor)) {
include $processor;
}
$class = "\\Todaymade\\Daux\\Extension\\" . $processor;
if (class_exists($class)) {
$daux->setProcessor(new $class($daux, $output, $width));
} else if (file_exists($processor)) {
include $processor;
}
}
// Improve the tree with a processor
$daux->getProcessor()->manipulateTree($daux->tree);
switch(strtolower($input->getOption('format'))) {
case 'confluence':
(new ConfluenceGenerator())->generate($daux, $output, $width);

38
libs/Processor.php Fichier normal
Voir le fichier

@ -0,0 +1,38 @@
<?php namespace Todaymade\Daux;
use League\CommonMark\Environment;
use Symfony\Component\Console\Output\OutputInterface;
use Todaymade\Daux\Tree\Directory;
class Processor
{
/**
* @var Daux
*/
protected $daux;
/**
* @var OutputInterface
*/
protected $output;
/**
* @var integer
*/
protected $width;
public function __construct(Daux $daux, OutputInterface $output, $width)
{
$this->daux = $daux;
$this->output = $output;
$this->width = $width;
}
public function manipulateTree(Directory $root)
{
}
public function extendCommonMarkEnvironment(Environment $environment)
{
}
}