|
11 | 11 | ->name('*.php') |
12 | 12 | ->in("$flarum/src"); |
13 | 13 |
|
| 14 | +// Get all tags and find latest minor of each major version |
| 15 | +$tags = explode("\n", trim(shell_exec("git -C $flarum tag"))); |
| 16 | +$latestMinors = []; |
| 17 | + |
| 18 | +foreach ($tags as $tag) { |
| 19 | + if (preg_match('/^v?([0-9]+)\.([0-9]+)\.[0-9]+$/', $tag, $matches)) { |
| 20 | + $major = $matches[1]; |
| 21 | + $minor = $matches[2]; |
| 22 | + $key = "$major.$minor"; |
| 23 | + |
| 24 | + // Store or update if this tag is newer |
| 25 | + if (!isset($latestMinors[$key]) || version_compare($tag, $latestMinors[$key], '>')) { |
| 26 | + $latestMinors[$key] = $tag; |
| 27 | + } |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +unset($latestMinors['1.0']); |
| 32 | +unset($latestMinors['1.1']); |
| 33 | +unset($latestMinors['1.2']); |
| 34 | + |
14 | 35 | $versions = GitVersionCollection::create($flarum) |
15 | | - ->addFromTags(function ($version) { |
16 | | - return preg_match('/^v?([0-9]+)\.([0-9]+)\.0$/', $version) && (preg_match('/^v1\.[0-2]/i', $version) === 0); |
17 | | - }) |
18 | | - ->add('main', 'main') |
| 36 | + ->add('1.x', '1.x') |
19 | 37 | ->add('2.x', '2.x'); |
20 | 38 |
|
| 39 | +foreach ($latestMinors as $key => $tag) { |
| 40 | + $versions->add($tag, $tag); |
| 41 | +} |
| 42 | + |
21 | 43 | return new Doctum($iterator, array( |
22 | 44 | 'theme' => 'flarum', |
23 | 45 | 'versions' => $versions, |
24 | 46 | 'title' => 'Flarum API', |
25 | 47 | 'build_dir' => __DIR__ . '/docs/php/%version%/', |
26 | 48 | 'cache_dir' => __DIR__ . '/cache/php/%version%/', |
27 | 49 | 'template_dirs' => array(__DIR__.'/themes/flarum'), |
28 | | - 'remote_repository' => new GitHubRemoteRepository('flarum/main', $flarum), |
| 50 | + 'remote_repository' => new GitHubRemoteRepository('flarum/framework', $flarum), |
29 | 51 | 'default_opened_level' => 1, |
30 | | - 'source_url' => 'https://github.com/flarum/main/', |
| 52 | + 'source_url' => 'https://github.com/flarum/framework/', |
31 | 53 | 'source_dir' => 'src' |
32 | 54 | )); |
0 commit comments