1414import argparse
1515import concurrent .futures
1616import os
17+ import shutil
1718import subprocess
1819import sys
1920import tempfile
@@ -147,6 +148,7 @@ def build_snapshots(
147148 verbose : bool ,
148149 view_filter : str | None = None ,
149150 is_test : bool = False ,
151+ keep_xml : bool = False ,
150152) -> None :
151153 if not is_test :
152154 configs_to_build = [
@@ -193,6 +195,7 @@ def build_snapshots(
193195 failed_views = ", " .join (name for name , _ in errors )
194196 raise RuntimeError (f"Failed to generate snapshots: { failed_views } " )
195197 else :
198+ work_dir = os .path .join (react_native_dir , "api" )
196199 snapshot = build_snapshot_for_view (
197200 api_view = "Test" ,
198201 react_native_dir = react_native_dir ,
@@ -203,8 +206,18 @@ def build_snapshots(
203206 codegen_platform = None ,
204207 verbose = verbose ,
205208 input_filter = input_filter ,
209+ work_dir = work_dir ,
206210 )
207211
212+ if keep_xml :
213+ xml_src = os .path .join (work_dir , "xml" )
214+ xml_dst = os .path .join (output_dir , "xml" )
215+ if os .path .exists (xml_dst ):
216+ shutil .rmtree (xml_dst )
217+ shutil .copytree (xml_src , xml_dst )
218+ if verbose :
219+ print (f"XML files saved to { xml_dst } " )
220+
208221 if verbose :
209222 print (snapshot )
210223
@@ -242,6 +255,11 @@ def main():
242255 action = "store_true" ,
243256 help = "Run on the local test directory instead of the react-native directory" ,
244257 )
258+ parser .add_argument (
259+ "--xml" ,
260+ action = "store_true" ,
261+ help = "Keep the generated Doxygen XML files next to the .api output in a xml/ directory" ,
262+ )
245263 args = parser .parse_args ()
246264
247265 verbose = not args .check
@@ -299,6 +317,7 @@ def main():
299317 input_filter = input_filter ,
300318 view_filter = args .view ,
301319 is_test = args .test ,
320+ keep_xml = args .xml ,
302321 )
303322
304323 if args .check :
0 commit comments