INNER CODE UNIT · Python
_extract_block_declaration
Kotlin/kandy · util/kandy-samples-utils/nb_to_doc.py:263
def _extract_block_declaration(lines: List[str], start_index: int, decl_type: str) -> Tuple[Tuple[str, str], int]:
"""
Extract a block declaration (class, function) from lines.
Args:
lines: List of code lines
start_index: Index to start extraction from
decl_type: Type of declaration ('class' or 'function')
Returns:
Tuple of ((declaration_type, declaration_text), new_index)
"""
line = lines[start_index].rstrip()
current_lines = [line]
brace_count = line.count('{') - line.count('}')
i = start_index + 1
while i < len(lines) and (brace_count > 0 or (brace_count == 0 and '{' not in line)):