def METHOD_NAME(self):
    gallerytype = self.arguments[0]
    includedocstring = True
    maxwidth = self.options.get('image-width',630 if gallerytype == 'databases' else 200)
    maxheight = self.options.get('image-height',150)
    maxcolumns = self.options.get('columns',1 if gallerytype == 'databases' else 3)
    #self.state.document.settings.env.images
    #builder=self.state.document.settings.env.app.builder
    buildertype = self.state.document.settings.env.app.builder.name
    outdir = self.state.document.settings.env.app.builder.outdir
    #docname=self.state.document.settings.env.docname
    imagewritedir = os.path.join(os.path.join(outdir,'_images'),gallerytype)
    imagereaddir = os.path.join(self.state.document.settings.env.srcdir,'..','images',gallerytype)
    imagelinkdir = '_images'
    linkdir = 'openravepy'
    imageext = 'jpg'
    try:
        os.makedirs(imagewritedir)
    except OSError:
        pass
    parentmodule = __import__('openravepy.'+gallerytype,fromlist=['openravepy'])
    modulenames = []
    for name in dir(parentmodule):
        if not name.startswith('__'):
            try:
                modulename = 'openravepy.'+gallerytype+'.'+name
                m=__import__(modulename,fromlist=['openravepy'])
                if type(m) is ModuleType:
                    docstring = ''
                    if m.__doc__ is not None and includedocstring:
                        endindex = m.__doc__.find('\n')
                        docstring = m.__doc__[:endindex] if endindex > 0 else ''
                    modulenames.append([modulename,name,docstring])
            except ImportError:
                pass
    # copy the images
    link_templates = {'html':'<td><p><b>%s</b></p><a href="%s.html"><img src="%s" border="0" class="thumbimage" alt="%s"/></a>%s</td>\n', 'json':'<td><p><b>%s</b></p><a href="../%s/"><img src="../%s" border="0" class="thumbimage" alt="../%s"/></a>%s</td>\n'}
    link_template = link_templates.get(buildertype,link_templates['html'])
    rows = []
    for modulename, name, docstring in modulenames:
        imthumbname = name+'_thumb.'+imageext
        try:
            im = Image.open(os.path.join(imagereaddir,name+'_thumb.'+imageext))
        except IOError:
            try:
                im = Image.open(os.path.join(imagereaddir,name+'.'+imageext))
            except IOError:
                im = None
        if im is not None:
            if im.size[0]*maxheight//im.size[1] > maxwidth:
                newsize = [maxwidth,im.size[1]*maxwidth//im.size[0]]
            else:
                newsize = [im.size[0]*maxheight//im.size[1],maxheight]
            imthumb = im.resize(newsize, Image.ANTIALIAS)
            with open(os.path.join(imagewritedir,imthumbname),'w') as f:
                imthumb.save(f)
            if len(docstring) > 0:
                docstring = '<p>%s</p>'%docstring
            rows.append(link_template%(name,linkdir+'/'+gallerytype+'.'+name, imagelinkdir+'/'+gallerytype+'/'+imthumbname, name,docstring))
    # have to have different links for different builders
    #for buildertype,link_template in link_templates.items():