diff --git a/composer.json b/composer.json index 1ddc56d..0284f31 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,9 @@ "symfony/finder": "~2.7" }, "autoload": { - "psr-4": {"Todaymade\\Daux\\": "libs/"} + "psr-4": { + "Todaymade\\Daux\\Extension\\": "daux/", + "Todaymade\\Daux\\": "libs/" + } } } diff --git a/daux.phar b/daux.phar index 8a13966..f903c1b 100755 Binary files a/daux.phar and b/daux.phar differ diff --git a/libs/Compiler.php b/libs/Compiler.php index b088a23..7029e2d 100644 --- a/libs/Compiler.php +++ b/libs/Compiler.php @@ -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'); diff --git a/libs/Daux.php b/libs/Daux.php index bdb65b3..f48151c 100644 --- a/libs/Daux.php +++ b/libs/Daux.php @@ -1,5 +1,6 @@ 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; + } } diff --git a/libs/Format/Base/CommonMark/CommonMarkConverter.php b/libs/Format/Base/CommonMark/CommonMarkConverter.php index c907050..41c4d9f 100644 --- a/libs/Format/Base/CommonMark/CommonMarkConverter.php +++ b/libs/Format/Base/CommonMark/CommonMarkConverter.php @@ -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); } diff --git a/libs/Generator/Command.php b/libs/Generator/Command.php index 3907056..0bca99d 100644 --- a/libs/Generator/Command.php +++ b/libs/Generator/Command.php @@ -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); diff --git a/libs/Processor.php b/libs/Processor.php new file mode 100644 index 0000000..1005f32 --- /dev/null +++ b/libs/Processor.php @@ -0,0 +1,38 @@ +daux = $daux; + $this->output = $output; + $this->width = $width; + } + + public function manipulateTree(Directory $root) + { + } + + public function extendCommonMarkEnvironment(Environment $environment) + { + } +}