Skip to content

Commit 27ff23b

Browse files
committed
Add an option to include raw XML files in the output
1 parent ae5b872 commit 27ff23b

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

.github/workflows/live-mix-into-source.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ jobs:
1313
TARGET_BRANCH_SUFFIX: '-mix-into-source'
1414
FLAVOR: mainline
1515
MIX_ANNOTATIONS_INTO_SOURCE: true
16+
INCLUDE_RAW_XML_SOURCE: true

.github/workflows/template.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ on:
3535
required: false
3636
default: false
3737
type: boolean
38+
INCLUDE_RAW_XML_SOURCE:
39+
description: 'Include raw XML source files'
40+
required: false
41+
default: false
42+
type: boolean
3843
workflow_call:
3944
inputs:
4045
BRANCH:
@@ -62,6 +67,11 @@ on:
6267
required: false
6368
default: false
6469
type: boolean
70+
INCLUDE_RAW_XML_SOURCE:
71+
description: 'Include raw XML source files'
72+
required: false
73+
default: false
74+
type: boolean
6575

6676
jobs:
6777
build:
@@ -155,11 +165,14 @@ jobs:
155165
remote_commit_hash=$(git rev-parse HEAD)
156166
message="Synced to commit ${remote_commit_hash}"
157167
cd ..
158-
mixAnnotationsIntoSource=""
168+
extraArgs=""
159169
if [[ "${{ inputs.MIX_ANNOTATIONS_INTO_SOURCE }}" == "true" ]]; then
160-
mixAnnotationsIntoSource="--mixAnnotationsIntoSource"
170+
extraArgs="${extraArgs} --mixAnnotationsIntoSource"
171+
fi
172+
if [[ "${{ inputs.INCLUDE_RAW_XML_SOURCE }}" == "true" ]]; then
173+
extraArgs="${extraArgs} --includeRawXmlSource"
161174
fi
162-
bin/annotate ${flavor} --inputDir=./.wow-ui-source/Interface --outputDir=./.annotations_temp/Annotations --linkPrefix="https://github.com/Gethe/wow-ui-source/blob/${branch_name}/Interface" ${mixAnnotationsIntoSource}
175+
bin/annotate ${flavor} --inputDir=./.wow-ui-source/Interface --outputDir=./.annotations_temp/Annotations --linkPrefix="https://github.com/Gethe/wow-ui-source/blob/${branch_name}/Interface" ${extraArgs}
163176
cd ./.annotations_temp
164177
git config user.name "GitHub Actions"
165178
git config user.email [email protected]

bin/annotate

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ require_once __DIR__ . '/../vendor/autoload.php';
3131
->addOption('outputDir', 'o', InputOption::VALUE_REQUIRED, 'Output directory', './.annotated')
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')
34-
->addOption('mixAnnotationsIntoSource', 'm', InputOption::VALUE_NONE, 'Include all lua source files, and add class annotations to the source files')
34+
->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')
3536
->setCode(function (InputInterface $input, ConsoleOutput $output) {
3637
$io = new SymfonyStyle($input, $output);
3738

3839
$outputDir = $input->getOption('outputDir');
3940
$inputDir = $input->getOption('inputDir');
4041
$linkPrefix = $input->getOption('linkPrefix');
4142
$mixAnnotationsIntoSource = $input->getOption('mixAnnotationsIntoSource');
43+
$includeRawXmlSource = $input->getOption('includeRawXmlSource');
4244
try {
4345
$flavor = FlavorEnum::from($input->getArgument('flavor'));
4446
} catch (Throwable) {
@@ -105,6 +107,9 @@ require_once __DIR__ . '/../vendor/autoload.php';
105107
foreach($fileList as $filePath) {
106108
if (str_ends_with($filePath, 'xml')) {
107109
$xmlFileParser->writeAnnotationsToFile($filePath, $outputDir, $inputDir, $linkPrefix);
110+
if ($includeRawXmlSource) {
111+
$xmlFileParser->writeRawXmlToFile($filePath, $outputDir, $inputDir);
112+
}
108113
} elseif (str_ends_with($filePath, 'lua')) {
109114
$luaFileParser->writeAnnotationsToFile($filePath, $outputDir, $inputDir);
110115
}

src/XmlFileParser.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,20 @@ public function writeAnnotationsToFile(string $filename, string $outDir, string
165165
file_put_contents($targetFile, $data);
166166
}
167167

168+
public function writeRawXmlToFile(string $filename, string $outDir, string $prefixToStrip): void
169+
{
170+
$targetFile = $filename;
171+
if (str_starts_with($targetFile, $prefixToStrip)) {
172+
$targetFile = substr($targetFile, strlen($prefixToStrip));
173+
}
174+
$targetFile = rtrim($outDir, '/') . '/' . ltrim($targetFile, '/');
175+
if (!is_dir(dirname($targetFile))) {
176+
mkdir($outDir . '/' . dirname($filename), recursive: true);
177+
}
178+
179+
copy($filename, $targetFile);
180+
}
181+
168182
private function childHasInterestingData(Frame $child): bool
169183
{
170184
return

0 commit comments

Comments
 (0)