def _thumbnail_div(subdir, full_dir, fname, snippet, is_backref=False):
    """Generates RST to place a thumbnail in a gallery"""
    thumb = os.path.join(full_dir, 'images', 'thumb', fname[:-3] + '.png')
    link_name = os.path.join(full_dir, fname).replace(os.path.sep, '_')
    ref_name = os.path.join(subdir, fname).replace(os.path.sep, '_')
    if ref_name.startswith('._'):
        ref_name = ref_name[2:]
    out = []
    out.append("""

.. raw:: html

    <div class="thumbnailContainer" tooltip="{}">

""".format(snippet))

    out.append('.. only:: html\n\n')
    out.append('  .. figure:: %s\n' % thumb)
    if link_name.startswith('._'):
        link_name = link_name[2:]
    if full_dir != '.':
        out.append('    :target: ./%s/%s.html\n\n' % (full_dir, fname[:-3]))
    else:
        out.append('    :target: ./%s.html\n\n' % link_name[:-3])
    out.append("""    :ref:`example_%s`


.. raw:: html

    </div>

""" % (ref_name))
    if is_backref:
        out.append(ref_name % '.. only:: not html\n\n  * :ref:`example_%s`')
    return ''.join(out)
dataset/ETHPy150Open scikit-learn/scikit-learn/doc/sphinxext/gen_rst.py/_thumbnail_div/swapped operands of `%`