From e7afd9aa28cda486de91a2d46bd60fbabd7b9392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Fri, 17 Jul 2015 18:34:00 +0200 Subject: [PATCH] Add a more advanced processor system --- composer.json | 5 ++- daux.phar | Bin 705961 -> 713814 bytes libs/Compiler.php | 22 ++++++---- libs/Daux.php | 26 ++++++++++++ .../Base/CommonMark/CommonMarkConverter.php | 3 ++ libs/Generator/Command.php | 12 ++++-- libs/Processor.php | 38 ++++++++++++++++++ 7 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 libs/Processor.php 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 8a139665acc66f44626543c9515ca2f522fb5314..f903c1b349c35f77e75574648f3f8505a9a6cbf0 100755 GIT binary patch delta 11900 zcma)C30PBC+D;S%A_|J)h8hqXKz4T#1r-HXRMaX_j1VEp)+AJHr%i2Vw5^V|o~fy8 zb-K9Ly0uyo!1gANPCFq?`_G`Aj=gPXy3Ep9{?5~*?JSesOcc1)DbfX01kJ5zX4EeJ^C37MHZ?7**{Aj4^$9y`;}%%y;xD!072S z3uAcS*%%k}O~GjGn>72g7>$Nxt&-#Zf;VH|&}#56j;^(qO}4Cgrl#g%b8Vy9n%P*> zcuLRYax5>r@LTa--z3QTrf+d)5gfPNNH((}lFd6A zISuwDvIe=MPE%sU@Gs*FOmnlM=(8Y_-bul3L zR+o)2qd$Yf*gp;Pr}}f!-|5e}&_&P1dTI0mjE4f_r_mgY+(*+UzOu z0R|X+l zsC}fwRMd&Ym2u+kIBppU$y~YiWNwJLR8nJ8hs>vFWQlK+x%et6`Ac{0`;ExYA0uK@ zqs6}Q(fwt1I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hFvbtHMW>^}Ak-F-HFj7Yg>E}AS{L9Q_@UEF4=~hp) zv7TNUj@6S~*+5-tX`qjVa<+<&ta@({A$y~Nme?j1EvotFG`1A9kl0AyB$bT?c%oa_ z94ju|>tm}=0mF?3WcsiIJ5+P_JD4iaG!go9n<&m3OyNY(=x0#Uq=zq>DEVtmC20LC z6K4Ixe=d&3t!97dXr}AToxK?DSS;JYUJSKxpqZL`x|z1AzlFZGsw_F^<*#g&*|a@Z zaKHWCLi=qUgV)y2>S`Rb!iV}6F`Ti8Af`o(Cy>%Y8(q%II{#z*30&OrR)09$;(-cZ zwa`5nIEMzzGKa=t_Z%{;WnoVmn*ZxCq>Z1}N^@ro8x7)jW+*RZS+0q-cI+*2dvnd$RKZw zR@3GQ%i0NMo7*Y(AKNKvijC5=+31yOmn|6s-m=lvq3_W9bocg5wh!t@v?EM*${!0I zhdmt=pr%8D2JIbFFnxoP<8+%Z6~Rv(^o1hsRNEB>^_}B-kni$>&NojDmcF%33hTd7 z4+?kjL<6gWh5UhI3!HohKlt)nr@=L+$5im(TKS;s4?CS;|MehktCjt~K~GcbQ`He> zo3*pOH=m90%8R0_ jl7Qd$f4umNDRZ9jTuj7Dsn^|uTOPHsaddFile($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) + { + } +}