rst_include/libs/lib_source_line.py
def divide_source_line_in_blocks(path_source_file: Union[str, pathlib.Path, IO[str]], source_lines: List[SourceLine]) -> List[Block]:
    """
    return blocks  - each block starts with ".." and ends with a line that does not begin with tab or blank
    or begins with .. (another block)
    trailing blank lines are part of the block

    >>> path_source_file = pathlib.Path('some_source_file')
    >>> divide_source_line_in_blocks(path_source_file, source_lines=[])
    []

    >>> # test ['a']
    >>> source_lines = list()
    >>> source_lines.append(lib_classes.SourceLine(line_number=4711, content='This is a test'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4712, content='a new block will only occur'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4713, content='on .. include:: some_file.txt:'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4714, content='.. include:: some_file.py'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4715, content='    :code: python'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4716, content='.. include:: some_file.yaml'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4717, content='    :code: yaml'))
    >>> blocks = divide_source_line_in_blocks(path_source_file, source_lines)
    >>> assert blocks[0].source == path_source_file
    >>> assert blocks[0].l_source_lines[0].line_number == 4711
    >>> assert blocks[0].l_source_lines[0].content == 'This is a test'
    >>> assert blocks[0].l_source_lines[1].line_number == 4712
    >>> assert blocks[0].l_source_lines[1].content == 'a new block will only occur'
    >>> assert blocks[1].source == path_source_file
    >>> assert blocks[1].l_source_lines[0].line_number == 4714
    >>> assert blocks[1].l_source_lines[0].content == '.. include:: some_file.py'
    >>> assert blocks[1].l_source_lines[1].line_number == 4715
    >>> assert blocks[1].l_source_lines[1].content == '    :code: python'
    >>> assert blocks[2].l_source_lines[0].line_number == 4716
    >>> assert blocks[2].l_source_lines[0].content == '.. include:: some_file.yaml'
    >>> assert blocks[2].l_source_lines[1].line_number == 4717
    >>> assert blocks[2].l_source_lines[1].content == '    :code: yaml'

    """
    blocks = list()                               # type: List[Block]
    block = lib_classes.Block(path_source_file)   # type: Block
    for source_line in source_lines:
        if source_line_starts_with_include_statement(source_line):
            append_non_empty_block(block, blocks)
            block = lib_classes.Block(path_source_file)
        block.l_source_lines.append(source_line)
    append_non_empty_block(block, blocks)
    return blocks

    return blocks  - each block starts with ".." and ends with a line that does not begin with tab or blank
    or begins with .. (another block)
    trailing blank lines are part of the block

    >>> path_source_file = pathlib.Path('some_source_file')
    >>> divide_source_line_in_blocks(path_source_file, source_lines=[])
    []

    >>> # test ['a']
    >>> source_lines = list()
    >>> source_lines.append(lib_classes.SourceLine(line_number=4711, content='This is a test'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4712, content='a new block will only occur'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4713, content='on .. include:: some_file.txt:'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4714, content='.. include:: some_file.py'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4715, content='    :code: python'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4716, content='.. include:: some_file.yaml'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4717, content='    :code: yaml'))
    >>> blocks = divide_source_line_in_blocks(path_source_file, source_lines)
    >>> assert blocks[0].source == path_source_file
    >>> assert blocks[0].l_source_lines[0].line_number == 4711
    >>> assert blocks[0].l_source_lines[0].content == 'This is a test'
    >>> assert blocks[0].l_source_lines[1].line_number == 4712
    >>> assert blocks[0].l_source_lines[1].content == 'a new block will only occur'
    >>> assert blocks[1].source == path_source_file
    >>> assert blocks[1].l_source_lines[0].line_number == 4714
    >>> assert blocks[1].l_source_lines[0].content == '.. include:: some_file.py'
    >>> assert blocks[1].l_source_lines[1].line_number == 4715
    >>> assert blocks[1].l_source_lines[1].content == '    :code: python'
    >>> assert blocks[2].l_source_lines[0].line_number == 4716
    >>> assert blocks[2].l_source_lines[0].content == '.. include:: some_file.yaml'
    >>> assert blocks[2].l_source_lines[1].line_number == 4717
    >>> assert blocks[2].l_source_lines[1].content == '    :code: yaml'

    
return blocks  - each block starts with ".." and ends with a line that does not begin with tab or blank
or begins with .. (another block)
trailing blank lines are part of the block




return blocks - each block starts with " .. " and ends with a line that does not begin with tab or blank or begins with .. ( another block ) trailing blank lines are part of the block
def divide_source_line_in_blocks(path_source_file: Union[str, pathlib.Path, IO[str]], source_lines: List[SourceLine]) -> List[Block]:
    blocks = list()                               
    block = lib_classes.Block(path_source_file)   
    for source_line in source_lines:
        if source_line_starts_with_include_statement(source_line):
            append_non_empty_block(block, blocks)
            block = lib_classes.Block(path_source_file)
        block.l_source_lines.append(source_line)
    append_non_empty_block(block, blocks)
    return blocks
def divide_source_line_in_blocks ( path_source_file : Union [ str , pathlib . Path , IO [ str ] ] , source_lines : List [ SourceLine ] ) -> List [ Block ] : blocks = list ( ) block = lib_classes . Block ( path_source_file ) for source_line in source_lines : if source_line_starts_with_include_statement ( source_line ) : append_non_empty_block ( block , blocks ) block = lib_classes . Block ( path_source_file ) block . l_source_lines . append ( source_line ) append_non_empty_block ( block , blocks ) return blocks
return blocks  - each block starts with ".." and ends with a line that does not begin with tab or blank
or begins with .. (another block)
trailing blank lines are part of the block
return blocks - each block starts with " .. " and ends with a line that does not begin with tab or blank or begins with .. ( another block ) trailing blank lines are part of the block
"""
    return blocks  - each block starts with ".." and ends with a line that does not begin with tab or blank
    or begins with .. (another block)
    trailing blank lines are part of the block

    >>> path_source_file = pathlib.Path('some_source_file')
    >>> divide_source_line_in_blocks(path_source_file, source_lines=[])
    []

    >>> # test ['a']
    >>> source_lines = list()
    >>> source_lines.append(lib_classes.SourceLine(line_number=4711, content='This is a test'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4712, content='a new block will only occur'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4713, content='on .. include:: some_file.txt:'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4714, content='.. include:: some_file.py'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4715, content='    :code: python'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4716, content='.. include:: some_file.yaml'))
    >>> source_lines.append(lib_classes.SourceLine(line_number=4717, content='    :code: yaml'))
    >>> blocks = divide_source_line_in_blocks(path_source_file, source_lines)
    >>> assert blocks[0].source == path_source_file
    >>> assert blocks[0].l_source_lines[0].line_number == 4711
    >>> assert blocks[0].l_source_lines[0].content == 'This is a test'
    >>> assert blocks[0].l_source_lines[1].line_number == 4712
    >>> assert blocks[0].l_source_lines[1].content == 'a new block will only occur'
    >>> assert blocks[1].source == path_source_file
    >>> assert blocks[1].l_source_lines[0].line_number == 4714
    >>> assert blocks[1].l_source_lines[0].content == '.. include:: some_file.py'
    >>> assert blocks[1].l_source_lines[1].line_number == 4715
    >>> assert blocks[1].l_source_lines[1].content == '    :code: python'
    >>> assert blocks[2].l_source_lines[0].line_number == 4716
    >>> assert blocks[2].l_source_lines[0].content == '.. include:: some_file.yaml'
    >>> assert blocks[2].l_source_lines[1].line_number == 4717
    >>> assert blocks[2].l_source_lines[1].content == '    :code: yaml'

    """ # type: List[Block] # type: Block
path_source_file
Union[str, pathlib.Path, IO[str]]
source_lines
List[SourceLine]