def _iter_lines_with_refs(lines):
    """Transform the input lines to add a ref before each section title.
    This is done by looking one line ahead and locate a title's underline,
    and add a ref before the title text.
    Dots in the version is converted into dash, and a ``v`` is prefixed.
    This makes Sphinx use them as HTML ``id`` verbatim without generating
    auto numbering (which would make the the anchors unstable).
    """
    prev = None
    for line in lines:
        # Transform the previous line to include an explicit ref.
        if _is_version_section_title_underline(prev, line):
            assert prev is not None
            vref = prev.split(None, 1)[0].replace(".", "-")
            yield f".. _`v{vref}`:"
            yield ""  # Empty line between ref and the title.
        if prev is not None:
            yield prev
        prev = line
    if prev is not None:
        yield prev
Transform the input lines to add a ref before each section title.
    This is done by looking one line ahead and locate a title's underline,
    and add a ref before the title text.
    Dots in the version is converted into dash, and a ``v`` is prefixed.
    This makes Sphinx use them as HTML ``id`` verbatim without generating
    auto numbering (which would make the the anchors unstable).
    
product/runtime/docs/sphinx/conf.py