code: def format_citations(zid, url='https://zenodo.org/', hits=10, tag_prefix='v'):
      
      # query for metadata
      url = ('{url}/api/records/?'
             'page=1&'
             'size={hits}&'
             'q=conceptrecid:"{id}"&'
             'sort=-version&'
             'all_versions=True'.format(id=zid, url=url, hits=hits))
      metadata = requests.get(url).json()
  
      lines = []
      for i, hit in enumerate(metadata['hits']['hits']):
          version = hit['metadata']['version'][len(tag_prefix):]
          lines.append('-' * len(version))
          lines.append(version)
          lines.append('-' * len(version))
          lines.append('')
          lines.append('.. image:: {badge}\n'
                       '   :target: {doi}'.format(**hit['links']))
          if i < hits - 1:
              lines.append('')
  
      return '\n'.join(lines)
docs: Query and format a citations page from Zenodo entries
  
      Parameters
      ----------
      zid : `int`, `str`
          the Zenodo ID of the target record
  
      url : `str`, optional
          the base URL of the Zenodo host, defaults to ``https://zenodo.org``
  
      hist : `int`, optional
          the maximum number of hits to show, default: ``10``
  
      tag_prefix : `str`, optional
          the prefix for git tags. This is removed to generate the section
          headers in the output RST
  
      Returns
      -------
      rst : `str`
          an RST-formatted string of DOI badges with URLs