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

Function process_markdown_file

ci/extract_cpp_doc_code.py:191–217  ·  view source on GitHub ↗
(md_path: Path, output_dir: Path)

Source from the content-addressed store, hash-verified

189
190
191def 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
220def generate_bazel_build(test_files: List[Path], output_dir: Path) -> None:

Callers 1

mainFunction · 0.85

Calls 9

extract_cpp_code_blocksFunction · 0.85
is_complete_exampleFunction · 0.85
wrap_code_as_testFunction · 0.85
generate_test_file_nameFunction · 0.85
readMethod · 0.65
infoMethod · 0.65
debugMethod · 0.65
writeMethod · 0.65
appendMethod · 0.45

Tested by

no test coverage detected