Add a more advanced processor system
This commit is contained in:
parent
8dd3c1d6f8
commit
e7afd9aa28
@ -20,6 +20,9 @@
|
|||||||
"symfony/finder": "~2.7"
|
"symfony/finder": "~2.7"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {"Todaymade\\Daux\\": "libs/"}
|
"psr-4": {
|
||||||
|
"Todaymade\\Daux\\Extension\\": "daux/",
|
||||||
|
"Todaymade\\Daux\\": "libs/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,7 @@ class Compiler
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Composer autoload
|
// Composer autoload
|
||||||
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/autoload.php'));
|
$this->addComposer($phar);
|
||||||
$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->addBinary($phar);
|
$this->addBinary($phar);
|
||||||
|
|
||||||
// Stubs
|
// Stubs
|
||||||
@ -99,6 +93,20 @@ class Compiler
|
|||||||
$phar->addFromString($path, $content);
|
$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)
|
private function addBinary($phar)
|
||||||
{
|
{
|
||||||
$content = file_get_contents(__DIR__ . '/../generate.php');
|
$content = file_get_contents(__DIR__ . '/../generate.php');
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php namespace Todaymade\Daux;
|
<?php namespace Todaymade\Daux;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Output\NullOutput;
|
||||||
use Todaymade\Daux\Tree\Builder;
|
use Todaymade\Daux\Tree\Builder;
|
||||||
|
|
||||||
class Daux
|
class Daux
|
||||||
@ -12,6 +13,11 @@ class Daux
|
|||||||
public $internal_base;
|
public $internal_base;
|
||||||
private $docs_path;
|
private $docs_path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Processor
|
||||||
|
*/
|
||||||
|
protected $processor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Tree\Entry
|
* @var Tree\Entry
|
||||||
*/
|
*/
|
||||||
@ -152,4 +158,24 @@ class Daux
|
|||||||
|
|
||||||
return $this->options;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
|||||||
|
|
||||||
$this->extendEnvironment($environment);
|
$this->extendEnvironment($environment);
|
||||||
|
|
||||||
|
//TODO :: finish
|
||||||
|
//$daux->getProcessor()->extendCommonMarkEnvironment($environment);
|
||||||
|
|
||||||
$this->docParser = new DocParser($environment);
|
$this->docParser = new DocParser($environment);
|
||||||
$this->htmlRenderer = new HtmlRenderer($environment);
|
$this->htmlRenderer = new HtmlRenderer($environment);
|
||||||
}
|
}
|
||||||
|
@ -33,11 +33,17 @@ class Command extends SymfonyCommand
|
|||||||
|
|
||||||
$processor = $input->getOption('processor');
|
$processor = $input->getOption('processor');
|
||||||
if (!empty($processor) && $processor != 'none') {
|
if (!empty($processor) && $processor != 'none') {
|
||||||
if (file_exists($processor)) {
|
$class = "\\Todaymade\\Daux\\Extension\\" . $processor;
|
||||||
include $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'))) {
|
switch(strtolower($input->getOption('format'))) {
|
||||||
case 'confluence':
|
case 'confluence':
|
||||||
(new ConfluenceGenerator())->generate($daux, $output, $width);
|
(new ConfluenceGenerator())->generate($daux, $output, $width);
|
||||||
|
38
libs/Processor.php
Normal file
38
libs/Processor.php
Normal file
@ -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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user