From 114a0f29b79d37a8560807e67709704f6162de3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Tue, 28 Jul 2015 17:26:35 +0200 Subject: [PATCH] Be able to set the source directory on command line --- daux.phar | Bin 716329 -> 720205 bytes libs/Console/Generate.php | 30 +++++++++++++++++------ libs/Daux.php | 50 +++++++++++++++----------------------- libs/Server/Server.php | 3 ++- 4 files changed, 43 insertions(+), 40 deletions(-) diff --git a/daux.phar b/daux.phar index 5d9df582e47e45f2b5f992b4888b9ddd98e6b794..a62cc9fc47de1539b3b8c88038855e2004bbf5ac 100755 GIT binary patch delta 8579 zcmb7J30RcX-k%p{AC|#^8Fq%9VH=P|lvR*LkxfAaL>OU!5tzZ5u|#vJ%=)fn<|&UY zE_kn7naic3#fq-=WQ(b3x5YB8)YP)P-=~jl`kizB?<{!f`R?cQjDOzu{MX-qd*_`! zUnU*>HR*tb6MbhE2nLXyo8;jXRaR{ zFxvEP7gX{*QAy2Ey3XT!t3xuAO6IvSkCCh}m^=H7R;u8b2PmMl;?PqQ9SRDl0`(XL zRR(Ksr{!+59{GK#3ZugBd4e#dHx4~2aR_Hq;ezpn-R@Eq9=v@@EvB7%hl)v5MYbEW zP4Bcn(`4?QWi)phtq{Y*B5;G!x~id_=!`TF)rcl2UnZbabSQ0}TxddzL=(N}jl%@4 znGG+5p&vv#maafCB)nFf!>-qgC$aPieFXyBfB&R)xD|(1NkZesByUIzMkw8^zntS> zokm&x87rjD>Aw@dxqR@HHf`6u<`B)JqIu(qx&cDbtKgG{7Fdddpq0Ac;NlL2^*rarHMpF#RRm3ty9g0*&A6KL?`mO?o)C~p9lV~p( zR&`!5jF49zE7lA$c#f3Lcn{U}sL)lfcqSa^UCs_qO9X=YBMXyIq<0e9=&fRhd%g1+ z{lR-GqiH@3j6UQuozYW1vl!L+Rxvv0TgT{8{yI!KlU?^I;rx)Yj2U}}g#Yo9)ALZf zUm7a#Q!}PUzZypO_yO}TesdV}CQ_3be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@4jal$37?a zIkV4&eXi_tW1laddOption('configuration', 'c', InputArgument::OPTIONAL, 'Configuration file') ->addOption('format', 'f', InputArgument::OPTIONAL, 'Output format, html or confluence', 'html') ->addOption('processor', 'p', InputArgument::OPTIONAL, 'Manipulations on the tree') + ->addOption('source', 's', InputArgument::OPTIONAL, 'Where to take the documentation from') ->addOption('destination', 'd', InputArgument::OPTIONAL, $description, 'static'); } protected function execute(InputInterface $input, OutputInterface $output) { - // Initialize the system - $daux = new Daux(Daux::STATIC_MODE); - $daux->initialize($input->getOption('configuration')); - - // Set the format if requested - if ($input->getOption('format')) { - $daux->getParams()['format'] = $input->getOption('format'); - } + $daux = $this->prepareDaux($input); $width = $this->getApplication()->getTerminalDimensions()[0]; @@ -45,6 +39,26 @@ class Generate extends SymfonyCommand $daux->getGenerator()->generateAll($input, $output, $width); } + protected function prepareDaux(InputInterface $input) { + $daux = new Daux(Daux::STATIC_MODE); + + // Set the format if requested + if ($input->getOption('format')) { + $daux->getParams()['format'] = $input->getOption('format'); + } + + // Set the source directory + if ($input->getOption('source')) { + $daux->getParams()['docs_directory'] = $input->getOption('source'); + } + + $daux->setDocumentationPath($daux->getParams()['docs_directory']); + + $daux->initializeConfiguration($input->getOption('configuration')); + + return $daux; + } + protected function prepareProcessor(Daux $daux, InputInterface $input, OutputInterface $output, $width) { if ($input->getOption('processor')) { diff --git a/libs/Daux.php b/libs/Daux.php index 146eddc..c55c37c 100644 --- a/libs/Daux.php +++ b/libs/Daux.php @@ -63,28 +63,25 @@ class Daux if (defined('PHAR_DIR')) { $this->local_base = PHAR_DIR; } + + // global.json + $this->loadBaseConfiguration(); } /** * @param string $override_file * @throws Exception */ - public function initialize($override_file = 'config.json') + public function initializeConfiguration($override_file = 'config.json') { - // global.json - $this->loadBaseConfiguration(); + // Read documentation overrides + $this->loadConfiguration($this->docs_path . DIRECTORY_SEPARATOR . 'config.json'); - // Check the documentation path - $this->docs_path = $this->options['docs_directory']; - if (!is_dir($this->docs_path) && - !is_dir($this->docs_path = $this->local_base . DIRECTORY_SEPARATOR . $this->docs_path) - ) { - throw new Exception('The Docs directory does not exist. Check the path again : ' . $this->docs_path); + // Read command line overrides + if (!is_null($override_file)) { + $this->loadConfiguration($this->local_base . DIRECTORY_SEPARATOR . $override_file); } - // /config.json, - $this->loadConfigurationOverrides($override_file); - // Set a valid default timezone if (isset($this->options['timezone'])) { date_default_timezone_set($this->options['timezone']); @@ -93,6 +90,16 @@ class Daux } } + public function setDocumentationPath($path) + { + $this->docs_path = $path; + if (!is_dir($this->docs_path) && + !is_dir($this->docs_path = $this->local_base . DIRECTORY_SEPARATOR . $this->docs_path) + ) { + throw new Exception('The Docs directory does not exist. Check the path again : ' . $this->docs_path); + } + } + /** * Load and validate the global configuration * @@ -112,25 +119,6 @@ class Daux $this->loadConfiguration($this->local_base . DIRECTORY_SEPARATOR . 'global.json', false); } - /** - * Load the configuration files, first, "config.json" - * in the documentation and then the file specified - * when running the configuration - * - * @param string $override_file - * @throws Exception - */ - protected function loadConfigurationOverrides($override_file) - { - // Read documentation overrides - $this->loadConfiguration($this->docs_path . DIRECTORY_SEPARATOR . 'config.json'); - - // Read command line overrides - if (!is_null($override_file)) { - $this->loadConfiguration($this->local_base . DIRECTORY_SEPARATOR . $override_file); - } - } - /** * @param string $config_file * @param bool $optional diff --git a/libs/Server/Server.php b/libs/Server/Server.php index f1ee380..42746e1 100644 --- a/libs/Server/Server.php +++ b/libs/Server/Server.php @@ -22,7 +22,8 @@ class Server public static function serve() { $daux = new Daux(Daux::LIVE_MODE); - $daux->initialize(); + $daux->setDocumentationPath($daux->getParams()['docs_directory']); + $daux->initializeConfiguration(); $class = $daux->getProcessorClass(); if (!empty($class)) {