Skip to content

Commit 9ae5955

Browse files
committed
-mix-into-source branches now also include TOC files (only for the specified flavor)
1 parent b9b27d3 commit 9ae5955

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

bin/annotate

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ require_once __DIR__ . '/../vendor/autoload.php';
3232
->addOption('inputDir', 'i', InputOption::VALUE_REQUIRED, 'Directory containing the files to annotate', '.')
3333
->addOption('linkPrefix', 'l', InputOption::VALUE_REQUIRED, 'Prefix for links in the output')
3434
->addOption('mixAnnotationsIntoSource', 'm', InputOption::VALUE_NONE, 'Include all Lua source files, and add class annotations to the source files')
35-
->addOption('includeRawXmlSource', 'x', InputOption::VALUE_NONE, 'Include the raw XML source files in the output')
35+
->addOption('includeRawXmlSource', 'x', InputOption::VALUE_NONE, 'Include the raw XML and TOC source files in the output')
3636
->setCode(function (InputInterface $input, ConsoleOutput $output) {
3737
$io = new SymfonyStyle($input, $output);
3838

@@ -78,7 +78,7 @@ require_once __DIR__ . '/../vendor/autoload.php';
7878
foreach (array_keys($dirsWithToc) as $dirWithToc) {
7979
$tocFile = $tocParser->findTocFile($dirWithToc);
8080
if ($tocFile) {
81-
$fileList = array_merge($fileList, $tocParser->listFiles($tocFile));
81+
$fileList = array_merge($fileList, $tocParser->listFiles($tocFile), [$tocFile]);
8282
}
8383
}
8484
}
@@ -112,6 +112,8 @@ require_once __DIR__ . '/../vendor/autoload.php';
112112
}
113113
} elseif (str_ends_with($filePath, 'lua')) {
114114
$luaFileParser->writeAnnotationsToFile($filePath, $outputDir, $inputDir);
115+
} elseif (isset($tocParser) && $includeRawXmlSource && str_ends_with($filePath, 'toc')) {
116+
$tocParser->writeRawTocToFile($filePath, $outputDir, $inputDir);
115117
}
116118
$progressBar->advance();
117119
}

src/TocFileParser.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,20 @@ public function listFiles(string $tocFilePath): array
128128
return $files;
129129
}
130130

131+
public function writeRawTocToFile(string $filename, string $outDir, string $prefixToStrip): void
132+
{
133+
$targetFile = $filename;
134+
if (str_starts_with($targetFile, $prefixToStrip)) {
135+
$targetFile = substr($targetFile, strlen($prefixToStrip));
136+
}
137+
$targetFile = rtrim($outDir, '/') . '/' . ltrim($targetFile, '/');
138+
if (!is_dir(dirname($targetFile))) {
139+
mkdir($outDir . '/' . dirname($filename), recursive: true);
140+
}
141+
142+
copy($filename, $targetFile);
143+
}
144+
131145
private function allowLoadGameType(string $gameTypes): bool
132146
{
133147
$gameTypesForFlavor = array_map(strtolower(...), $this->getGameTypesForFlavor($this->flavor));

0 commit comments

Comments
 (0)