def parse_to_spans(byte_array: bytearray) -> Dict[str, List[List[int]]]:
comment_spans = []  <EOL>comment_spans_append = comment_spans.append<EOL>extension_tag_spans = []  <EOL>extension_tag_spans_append = extension_tag_spans.append<EOL>wikilink_spans = []  <EOL>wikilink_spans_append = wikilink_spans.append<EOL>parameter_spans = []  <EOL>parameter_spans_append = parameter_spans.append<EOL>parser_function_spans = []  <EOL>parser_function_spans_append = parser_function_spans.append<EOL>template_spans = []  <EOL>template_spans_append = template_spans.append<EOL>for match in COMMENT_FINDITER(byte_array):<EOL><INDENT>ms, me = match.span()<EOL>comment_spans_append([ms, me])<EOL>byte_array[ms:me] = b'<STR_LIT:U+0020>' * (me - ms)<EOL><DEDENT>for match in EXTENSION_TAGS_FINDITER(byte_array):<EOL><INDENT>ms, me = match.span()<EOL>extension_tag_spans_append([ms, me])<EOL>if match[<NUM_LIT:2>]:  <EOL><INDENT>parse_tag_extensions(<EOL>byte_array, ms, me,<EOL>wikilink_spans_append,<EOL>parameter_spans_append,<EOL>parser_function_spans_append,<EOL>template_spans_append)<EOL><DEDENT>byte_array[ms:me] = b'<STR_LIT:_>' * (me - ms)<EOL><DEDENT>while True:<EOL><INDENT>match = None<EOL>for match in WIKILINK_FINDITER(byte_array):<EOL><INDENT>ms, me = match.span()<EOL>wikilink_spans_append([ms, me])<EOL>parse_pm_pf_tl(<EOL>byte_array, ms, me,<EOL>parameter_spans_append,<EOL>parser_function_spans_append,<EOL>template_spans_append)<EOL>byte_array[ms:me] = b'<STR_LIT:_>' * (me - ms)<EOL><DEDENT>if match is None:<EOL><INDENT>break<EOL><DEDENT><DEDENT>parse_pm_pf_tl(<EOL>byte_array, <NUM_LIT:0>, None,<EOL>parameter_spans_append,<EOL>parser_function_spans_append,<EOL>template_spans_append)<EOL>return {<EOL>'<STR_LIT>': sorted(comment_spans),<EOL>'<STR_LIT>': sorted(extension_tag_spans),<EOL>'<STR_LIT>': sorted(parameter_spans),<EOL>'<STR_LIT>': sorted(parser_function_spans),<EOL>'<STR_LIT>': sorted(template_spans),<EOL>'<STR_LIT>': sorted(wikilink_spans)}<EOL>
Calculate and set self._type_to_spans.

    The result is a dictionary containing lists of spans:
    {
        'Comment': comment_spans,
        'ExtTag': extension_tag_spans,
        'Parameter': parameter_spans,
        'ParserFunction': parser_function_spans,
        'Template': template_spans,
        'WikiLink': wikilink_spans,
    }