@classmethod<EOL><INDENT>def process_doc(cls, doc, handler):<EOL><DEDENT>
assert isinstance(doc, six.text_type),'<STR_LIT>' % type(doc)<EOL>cur_index = <NUM_LIT:0><EOL>parts = []<EOL>for match in doc_ref_re.finditer(doc):<EOL><INDENT>start, end = match.span()<EOL>parts.append(doc[cur_index:start])<EOL>cur_index = end<EOL>tag = match.group('<STR_LIT>')<EOL>val = match.group('<STR_LIT>')<EOL>sub = handler(tag, val)<EOL>parts.append(sub)<EOL><DEDENT>parts.append(doc[cur_index:])<EOL>return '<STR_LIT>'.join(parts)<EOL>
Helper for parsing documentation references in Stone docstrings and
replacing them with more suitable annotations for the generated output.

Args:
    doc (str): A Stone docstring.
    handler: A function with the following signature:
        `(tag: str, value: str) -> str`. It will be called for every
        reference found in the docstring with the tag and value parsed
        for you. The returned string will be substituted in the
        docstring in place of the reference.