(md_path: Path, output_dir: Path)
| 189 | |
| 190 | |
| 191 | def process_markdown_file(md_path: Path, output_dir: Path) -> List[Path]: |
| 192 | # logging.info(f"Processing {md_path}") |
| 193 | |
| 194 | with open(md_path, "r", encoding="utf-8") as f: |
| 195 | content = f.read() |
| 196 | |
| 197 | code_blocks = extract_cpp_code_blocks(content) |
| 198 | logging.info(f" Found {len(code_blocks)} C++ code blocks") |
| 199 | |
| 200 | generated_files = [] |
| 201 | |
| 202 | for i, (code, line_num) in enumerate(code_blocks): |
| 203 | if not is_complete_example(code): |
| 204 | logging.debug(f" Skipping incomplete example at line {line_num}") |
| 205 | continue |
| 206 | |
| 207 | test_content = wrap_code_as_test(code, md_path.name, i) |
| 208 | test_file_name = generate_test_file_name(md_path.name, i) |
| 209 | test_path = output_dir / test_file_name |
| 210 | |
| 211 | with open(test_path, "w", encoding="utf-8") as f: |
| 212 | f.write(test_content) |
| 213 | |
| 214 | generated_files.append(test_path) |
| 215 | logging.info(f" Generated {test_file_name}") |
| 216 | |
| 217 | return generated_files |
| 218 | |
| 219 | |
| 220 | def generate_bazel_build(test_files: List[Path], output_dir: Path) -> None: |
no test coverage detected