Changeset 74973 in spip-zone
- Timestamp:
- Aug 26, 2013, 6:21:45 PM (8 years ago)
- Location:
- _galaxie_/code.spip.net/autodoc/trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
_galaxie_/code.spip.net/autodoc/trunk/bin/autodoc_helper.php
r74941 r74973 19 19 $app = new \Cilex\Application('Autodoc Generator Helper', '1.0.0'); 20 20 $app->command(new autodoc\Helpers\Command\FromSvn()); 21 $app->command(new autodoc\Helpers\Command\FromDirectory()); 21 22 $app->run(); -
_galaxie_/code.spip.net/autodoc/trunk/installation.md
r74963 r74973 145 145 146 146 147 #### from:directory 148 149 Générer la documentation depuis un répertoire quelconque. 150 Par défaut, la sortie est enregistrée dans le répertoire `work/output/default` 151 152 php autodoc/bin/autodoc_helper.php from:directory /home/marcimat/www/spip-dev 153 154 Forcer un préfixe de sortie ici dans `work/output/spip-dev` : 155 156 php autodoc/bin/autodoc_helper.php from:directory /home/marcimat/www/spip-dev --prefixe=spip-dev 157 158 147 159 #### from:svn 148 160 149 161 Générer la documentation depuis une source SVN quelconque. 150 Par défaut, la sortie est enregistrée dans le répertoire `work/output/default`151 162 152 163 php autodoc/bin/autodoc_helper.php from:svn svn://trac.rezo.net/spip/spip 153 154 Forcer un préfixe de sortie ici dans `work/output/spip-dev` :155 156 php autodoc/bin/autodoc_helper.php from:svn svn://trac.rezo.net/spip/spip --prefixe=spip-dev157 164 158 165 -
_galaxie_/code.spip.net/autodoc/trunk/src/autodoc/Application.php
r74595 r74973 8 8 use phpDocumentor\Application as phpDocumentor; 9 9 use phpDocumentor\Console\Output\Output as ConsoleOutput; 10 use Symfony\Component\Console\Input\StringInput; 10 11 11 12 /** … … 56 57 } 57 58 59 60 /** 61 * Run the application with command as string 62 * 63 * @example 64 * $app->run_with_command("project:run --config=phpdoc.xml"); 65 * 66 * @param bool $interactive Whether to run in interactive mode. 67 * 68 * @return void 69 */ 70 public function run_with_command($command = "") 71 { 72 /** @var ConsoleApplication $app */ 73 $app = $this['console']; 74 $app->setAutoExit(false); 75 76 77 $output = new ConsoleOutput(); 78 $output->setLogger($this['monolog']); 79 80 $app->run(new StringInput($command), $output); 81 } 58 82 } 59 83 -
_galaxie_/code.spip.net/autodoc/trunk/src/autodoc/Helpers/Command/FromSvn.php
r74968 r74973 2 2 3 3 /* 4 * Commande d'ex ecution …4 * Commande d'exécution depuis une source svn … 5 5 */ 6 6 … … 14 14 use autodoc\Helpers\Generator; 15 15 16 16 17 /** 17 * Exécuter l'application…18 * Déclaration et exécution de l'application depuis un svn 18 19 */ 19 20 class FromSvn extends Command -
_galaxie_/code.spip.net/autodoc/trunk/src/autodoc/Helpers/Generator.php
r74968 r74973 7 7 namespace autodoc\Helpers; 8 8 9 use Cilex\Command\Command;10 use Symfony\Component\Console\Input\InputArgument;11 9 use Symfony\Component\Console\Input\InputInterface; 12 use Symfony\Component\Console\Input\InputOption;13 10 use Symfony\Component\Console\Output\OutputInterface; 14 use autodoc\ Helpers\Generator;11 use autodoc\Application; 15 12 16 13 /** … … 22 19 private $output; 23 20 24 private $dirs = array(); 25 21 private $dirs = array(); 22 private $files = array(); 23 private $options = array('dirs' => array()); // forcer des répertoires en dehors des options de ligne de commande 24 25 /** 26 * Description de la documentation à générer 27 * @var string $description */ 28 private $description = ""; 29 30 /** 31 * Présentation de la documentation à générer 32 * @var string $presentation */ 33 private $presentation = ""; 34 35 /** 36 * Constructeur 37 * 38 * @param InputInterface $input 39 * @param OutputInterface $output 40 **/ 26 41 public function __construct(InputInterface $input, OutputInterface $output) 27 42 { … … 29 44 $this->output = $output; 30 45 46 $this->setApplicationDirectories(); 47 } 48 49 50 /** 51 * Générer la documentation à partir d'une url SVN 52 * 53 * @param string $source URL SVN 54 **/ 55 public function generateFromSvn($source) { 56 $prefixe = $this->input->getOption('prefixe'); 57 $ok = $this->createDirectories($prefixe) 58 && $this->getSvnSource($source) 59 && $this->generateFromDirectory($this->dirs['input'], true); 60 return $ok; 61 } 62 63 64 /** 65 * Générer la documentation à partir d'un répertoire indiqué 66 * 67 * @param string $dir Chemin du répertoire source 68 * @param bool $is_ready 69 * Indique si les préparatifs (création des répertoires) sont déjà faits 70 **/ 71 public function generateFromDirectory($dir, $is_ready = false) { 72 $prefixe = $this->input->getOption('prefixe'); 73 $ok = true; 74 75 if (!$is_ready) { 76 # forcer le chemin de la source spécifique 77 $this->options['dirs']['input'] = $dir; 78 $ok = $this->createDirectories($prefixe); 79 } 80 $ok = $ok 81 && $this->prepareConfigXml(); 82 83 if (!$ok) { 84 return false; 85 } 86 87 $this->execute(); 88 } 89 90 91 /** 92 * Définit les répertoires utiles à l'application 93 **/ 94 private function setApplicationDirectories() { 31 95 # ce répertoire 32 96 $this->dirs['helper'] = realpath(__DIR__); … … 41 105 # répertoire de travail (celui où on écrira tout). 42 106 $this->dirs['work'] = $this->dirs['root'] . '/work'; 43 } 44 45 /** 46 * Générer la documentation à partir d'une url SVN 47 * 48 * @param string $source URL SVN 49 **/ 50 public function generateFromSvn($source) { 51 $prefixe = $this->input->getOption('prefixe'); 52 $this->createDirectories($prefixe); 53 $this->getSvnSource($source); 54 } 55 56 57 /** 58 * Crée les répertoires nécessaires au fonctionnement de ce programme 107 108 $this->files['phpdoc.xml'] = $this->dirs['work'] . '/phpdoc.xml'; 109 } 110 111 112 /** 113 * Définit et crée les répertoires nécessaires au fonctionnement de ce programme 59 114 * 60 115 * @param string $prefixe Préfixe utilisé pour cette génération … … 65 120 $this->output->writeln("* Vérifier/créer les répertoires de travail dans <info>$_work</info>"); 66 121 67 $this->dirs['output'] = $_work . '/' . "output/$prefixe"; 68 $this->dirs['input'] = $_work . '/' . "input/$prefixe"; 69 $this->dirs['log'] = $_work . '/' . "log/$prefixe"; 70 $this->dirs['cache'] = $_work . '/' . "cache/$prefixe"; 122 foreach (array('output', 'input', 'log', 'cache') as $dir) { 123 // valeur par défaut, en fonction du préfixe 124 $this->dirs[$dir] = "$_work/$dir/$prefixe"; 125 126 // valeur forcée dans certains cas 127 if (isset($this->options['dirs'][$dir]) and $path = $this->options['dirs'][$dir]) { 128 $this->dirs[$dir] = $path; 129 } 130 } 71 131 72 132 foreach (array('output', 'input', 'log', 'cache') as $dir) { … … 92 152 $this->output->writeln(" - Création du répertoire <info>$dir</info>"); 93 153 94 if (!@mkdir($ _dir, 0755, true)) {154 if (!@mkdir($dir, 0755, true)) { 95 155 $this->output->writeln("<error>Impossible de créer le répertoire : $dir</error>"); 96 156 $error = error_get_last(); … … 144 204 145 205 if (!$this->makeSvnCommand("checkout $source .")) { 146 $this->output->writeln(" [<error>Echec</error>]");206 $this->output->writeln("<error>[Echec]</error>"); 147 207 return false; 148 208 } 149 209 150 210 $last = array_pop($res); 151 $this->output->writeln(" [<info>OK</info>]($last)");211 $this->output->writeln("<info>[OK]</info> ($last)"); 152 212 return true; 153 213 } … … 199 259 return true; 200 260 } 261 262 263 /** 264 * Utilise le template de configuration phpdoc.xml en modifiant ses variables 265 * et l'enregistre pour qu'il soit utilisé par l'application 266 * 267 * @return bool true si réussi. 268 **/ 269 private function prepareConfigXml() { 270 271 $this->output->write("* Préparer le fichier phpdoc.xml "); 272 $template = $this->dirs['helper'] . '/phpdoc_helper.xml'; 273 $template = file_get_contents($template); 274 275 $substitutions = array( 276 '@DIR_CACHE@' => $this->dirs['cache'], 277 '@DIR_OUTPUT@' => $this->dirs['output'], 278 '@DIR_INPUT@' => $this->dirs['input'], 279 '@DIR_LOG@' => $this->dirs['log'], 280 '@DIR_ROOT@' => $this->dirs['root'], 281 ); 282 283 $template = str_replace(array_keys($substitutions), array_values($substitutions), $template); 284 285 $destination = $this->dirs['work'] . '/phpdoc.xml'; 286 @unlink($destination); 287 288 if (!@file_put_contents($this->files['phpdoc.xml'], $template)) { 289 $this->output->writeln("<error>[Echec]</error>"); 290 return false; 291 } 292 293 $this->output->writeln("<info>[OK]</info>"); 294 return true; 295 } 296 297 298 /** 299 * Exécute l'application phpDocumentor avec le phpdoc.xml qui a été créé 300 * 301 * @return bool true si réussi. 302 **/ 303 private function execute() { 304 $conf = $this->files['phpdoc.xml']; 305 $command = "project:run --config=$conf --parseprivate"; 306 307 $app = new Application(); 308 $app->run_with_command($command); 309 } 201 310 } -
_galaxie_/code.spip.net/autodoc/trunk/src/autodoc/Helpers/phpdoc_helper.xml
r74941 r74973 4 4 <default-package-name>SPIP</default-package-name> 5 5 <encoding>utf-8</encoding> 6 <target> work/cache/@PREFIXE@</target>6 <target>@DIR_CACHE@</target> 7 7 <markers> 8 8 <item>TODO</item> … … 15 15 </parser> 16 16 <files> 17 <directory>@DIR_INPUT@</directory> 18 17 19 <ignore-hidden>on</ignore-hidden> 18 20 <ignore-symlinks>on</ignore-symlinks> … … 31 33 32 34 <ignore>squelettes-dist/*</ignore> 35 36 33 37 </files> 34 38 <transformer> 35 <target> work/output/@PREFIXE@</target>39 <target>@DIR_OUTPUT@</target> 36 40 </transformer> 37 41 <logging> 38 42 <level>warn</level> 39 43 <paths> 40 <default> work/log/@PREFIXE@/phpdoc-{DATE}.log</default>41 <errors> work/log/@PREFIXE@/phpdoc-{DATE}.errors.log</errors>44 <default>@DIR_LOG@/phpdoc-{DATE}.log</default> 45 <errors>@DIR_LOG@/phpdoc-{DATE}.errors.log</errors> 42 46 </paths> 43 47 </logging> 44 48 <transformations> 45 <template name=" autodoc/templates/zora" />49 <template name="@DIR_ROOT@/autodoc/templates/zora" /> 46 50 </transformations> 47 51 48 52 <options> 53 <description value="Documentation du code PHP de SPIP." /> 54 <presentation value="Cette documentation est extraite à partir du code source de la version de développement." /> 55 <!-- 49 56 <site value="http://code.spip.net/" /> 50 57 <proposer value="oui" /> 51 <description value="Documentation automatique du code PHP de SPIP." /> 52 <presentation value="Cette documentation est extraite automatiquement à partir du code source 53 PHP de la version en développement de SPIP." /> 54 <!--chemin value="autodoc/" / --> 58 <chemin value="autodoc/" /> 59 --> 55 60 </options> 56 61 </phpdocumentor>
Note: See TracChangeset
for help on using the changeset viewer.