MCPcopy Create free account
hub / github.com/apache/fory / main

Function main

ci/extract_cpp_doc_code.py:266–321  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

264
265
266def main():
267 parser = argparse.ArgumentParser(
268 description="Extract C++ code examples from markdown documentation"
269 )
270 parser.add_argument(
271 "--docs-dir",
272 default="docs/guide/cpp",
273 help="Directory containing markdown documentation files",
274 )
275 parser.add_argument(
276 "--output-dir",
277 default="cpp/doc_tests",
278 help="Output directory for generated test files",
279 )
280 parser.add_argument(
281 "--generate-build",
282 action="store_true",
283 help="Generate Bazel BUILD file",
284 )
285 parser.add_argument(
286 "--verbose",
287 "-v",
288 action="store_true",
289 help="Enable verbose output",
290 )
291
292 args = parser.parse_args()
293
294 if args.verbose:
295 logging.getLogger().setLevel(logging.DEBUG)
296
297 script_dir = Path(__file__).parent
298 project_root = script_dir.parent
299 docs_dir = project_root / args.docs_dir
300 output_dir = project_root / args.output_dir
301
302 if not docs_dir.exists():
303 logging.error(f"Documentation directory not found: {docs_dir}")
304 sys.exit(1)
305
306 output_dir.mkdir(parents=True, exist_ok=True)
307
308 all_test_files = []
309
310 for md_file in sorted(docs_dir.glob("*.md")):
311 test_files = process_markdown_file(md_file, output_dir)
312 all_test_files.extend(test_files)
313
314 logging.info(f"\nTotal: Generated {len(all_test_files)} test files")
315
316 if args.generate_build and all_test_files:
317 generate_bazel_build(all_test_files, output_dir)
318
319 print(f"\nGenerated files in {output_dir}:")
320 for f in sorted(all_test_files):
321 print(f" {f.name}")
322
323

Callers 1

Calls 6

process_markdown_fileFunction · 0.85
generate_bazel_buildFunction · 0.85
getLoggerMethod · 0.80
extendMethod · 0.80
errorMethod · 0.65
infoMethod · 0.65

Tested by

no test coverage detected