INNER CODE UNIT · Python
create_kt_file
Kotlin/kandy · util/kandy-samples-utils/nb_to_doc.py:422
def create_kt_file(kt_filename: str, cells: List[Tuple[NotebookNode, Optional[str], Optional[str]]], base_name: str) -> None:
"""
Creates a Kotlin test file preserving order of code cells.
Args:
kt_filename: Path to the output Kotlin file
cells: List of tuples containing (cell, output_type, output_content)
base_name: Base name for function names and class names
"""
try:
# Collect all definitions and imports
defs, imports = _collect_definitions_and_imports(cells)
with open(kt_filename, "w", encoding="utf-8") as kt_file:
_write_kt_file_header(kt_file, base_name)
_write_kt_file_imports(kt_file, imports)
_write_kt_file_definitions(kt_file, defs, base_name)
_write_kt_file_tests(kt_file, cells, base_name)