def pprint_cache(doc: Doc):
    """Pretty print cache content as a matrix."""
    idx = {}
    for iref, action in changes(doc):
        idx[int(iref.imag)] = action
    markers = '0123456789'
    header = ' ' * 6 + markers
    print(header)
    line = ''
    for i, x in enumerate(doc.cache):
        status = idx.get(i, 'x')
        if status == 'x' and doc.cache[i] is None:
            status = '-'
        line += status
        if i % 10 == 9 or i == len(doc.cache) - 1:
            prefix = f"{(i-i%10)//10}_"
            line = f"{prefix:>5} " + line
            print(line)
            line = ''
    print(line)
    return
Pretty print cache content as a matrix.
pdfsyntax/docstruct.py