|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @package Joomla.Internal-Documentation |
| 4 | + * |
| 5 | + * @copyright Copyright (C) 2022 Open Source Matters, Inc. All rights reserved. |
| 6 | + * @license GNU General Public License version 2 or later; see LICENSE.txt |
| 7 | + */ |
| 8 | + |
| 9 | +use Robo\Symfony\ConsoleIO; |
| 10 | +use Robo\Tasks; |
| 11 | + |
| 12 | +require_once 'vendor/autoload.php'; |
| 13 | + |
| 14 | +/** |
| 15 | + * Modern php task runner for Joomla! Browser Automated Tests execution |
| 16 | + * |
| 17 | + * @package RoboFile |
| 18 | + * |
| 19 | + * @since 1.0 |
| 20 | + */ |
| 21 | +class RoboFile extends Tasks |
| 22 | +{ |
| 23 | + protected $config; |
| 24 | + |
| 25 | + public function buildApidocu(ConsoleIO $io, $opts = ['fw' => '2']) |
| 26 | + { |
| 27 | + $this->reposCheckout($io, $opts); |
| 28 | + $this->generatePhpdocu($io, $opts); |
| 29 | + } |
| 30 | + |
| 31 | + public function reposCheckout(ConsoleIO $io, $opts = ['fw' => '2']) |
| 32 | + { |
| 33 | + $this->say('Checking out correct version of the framework repos'); |
| 34 | + |
| 35 | + if (!$this->config) |
| 36 | + { |
| 37 | + $this->config = \Symfony\Component\Yaml\Yaml::parseFile(__DIR__ . '/packages.yml'); |
| 38 | + } |
| 39 | + |
| 40 | + $taglessDirectories = [ |
| 41 | + 'datetime', |
| 42 | + 'mediawiki-api', |
| 43 | + 'renderer', |
| 44 | + 'symfony-event-dispatcher-bridge' |
| 45 | + ]; |
| 46 | + |
| 47 | + foreach ($this->config['packages'] as $name => $package) |
| 48 | + { |
| 49 | + if (is_null($package) || (is_array($package) && !(isset($package['deprecated']) || isset($package['abandoned'])))) |
| 50 | + { |
| 51 | + $repo = $name; |
| 52 | + |
| 53 | + if (isset($package['repo'])) |
| 54 | + { |
| 55 | + $repo = $package['repo']; |
| 56 | + } |
| 57 | + |
| 58 | + $this->say('Repository: ' . $name . ' (' . $repo . ')'); |
| 59 | + |
| 60 | + if (!is_dir(__DIR__ . '/repos/' . $name)) |
| 61 | + { |
| 62 | + $this->say('Clone repo'); |
| 63 | + system('git clone https://github.com/joomla-framework/' . $repo . '.git ./repos/' . $name); |
| 64 | + } |
| 65 | + |
| 66 | + chdir(__DIR__ . '/repos/' . $name); |
| 67 | + $tag = system('git tag -l "' . $opts['fw'] . '.*"'); |
| 68 | + system("git checkout tags/$tag"); |
| 69 | + |
| 70 | + chdir(__DIR__ . '/'); |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + $this->say('Repos have been checked out.'); |
| 75 | + } |
| 76 | + |
| 77 | + public function generatePhpdocu(ConsoleIO $io, $opts = ['fw' => '2']) |
| 78 | + { |
| 79 | + $this->say('Generate API documentation using phpDocumentor for Joomla Framework ' . $opts['fw'] . '.x packages'); |
| 80 | + $this->_exec('php phpDocumentor.phar -d ./repos/*/src -t ./build/api-docs/v' . $opts['fw'] . '/ --template ./ --title "Joomla! Framework ' . $opts['fw'] . '.x API" -i ./repos/string/src/phputf8'); |
| 81 | + } |
| 82 | +} |
0 commit comments