1414import argparse
1515import concurrent .futures
1616import os
17+ import shutil
1718import subprocess
1819import sys
1920import tempfile
@@ -140,6 +141,7 @@ def build_snapshots(
140141 verbose : bool ,
141142 view_filter : str | None = None ,
142143 is_test : bool = False ,
144+ keep_xml : bool = False ,
143145) -> None :
144146 if not is_test :
145147 configs_to_build = [
@@ -203,6 +205,7 @@ def build_snapshots(
203205 failed_views = ", " .join (name for name , _ in errors )
204206 raise RuntimeError (f"Failed to generate snapshots: { failed_views } " )
205207 else :
208+ work_dir = os .path .join (react_native_dir , "api" )
206209 snapshot = build_snapshot_for_view (
207210 api_view = "Test" ,
208211 react_native_dir = react_native_dir ,
@@ -213,8 +216,18 @@ def build_snapshots(
213216 codegen_dir = None ,
214217 verbose = verbose ,
215218 input_filter = input_filter ,
219+ work_dir = work_dir ,
216220 )
217221
222+ if keep_xml :
223+ xml_src = os .path .join (work_dir , "xml" )
224+ xml_dst = os .path .join (output_dir , "xml" )
225+ if os .path .exists (xml_dst ):
226+ shutil .rmtree (xml_dst )
227+ shutil .copytree (xml_src , xml_dst )
228+ if verbose :
229+ print (f"XML files saved to { xml_dst } " )
230+
218231 if verbose :
219232 print (snapshot )
220233
@@ -252,6 +265,11 @@ def main():
252265 action = "store_true" ,
253266 help = "Run on the local test directory instead of the react-native directory" ,
254267 )
268+ parser .add_argument (
269+ "--xml" ,
270+ action = "store_true" ,
271+ help = "Keep the generated Doxygen XML files next to the .api output in a xml/ directory" ,
272+ )
255273 args = parser .parse_args ()
256274
257275 verbose = not args .check
@@ -309,6 +327,7 @@ def main():
309327 input_filter = input_filter ,
310328 view_filter = args .view ,
311329 is_test = args .test ,
330+ keep_xml = args .xml ,
312331 )
313332
314333 if args .check :
0 commit comments