INNER CODE UNIT · Python

_collect_definitions_and_imports

Kotlin/kandy · util/kandy-samples-utils/nb_to_doc.py:446

def _collect_definitions_and_imports(cells: List[Tuple[NotebookNode, Optional[str], Optional[str]]]) -> Tuple[List[str], List[str]]:
    """
    Collect all definitions and imports from code cells.

    Args:
        cells: List of tuples containing (cell, output_type, output_content)

    Returns:
        Tuple of (definitions, imports)
    """
    defs = []
    imports = []

    for cell, _, _ in cells:
        if cell.cell_type == "code":
            cell_decls_all = extract_declarations(cell.source)
            cell_imports = [decl for decl in cell_decls_all if decl.startswith('import')]
            cell_defs = [decl for decl in cell_decls_all if not decl.startswith('import')]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…