code: def build_finished(app, exception):
      ''' Generate a ``sitemap.txt`` from the collected HTML page links.
  
      '''
      filename = join(app.outdir, "sitemap.txt")
  
      links_iter = status_iterator(sorted(app.sitemap_links),
                                   'adding links to sitemap... ',
                                   'brown',
                                   len(app.sitemap_links),
                                   app.verbosity)
  
      try:
          with open(filename, 'w') as f:
              for link in links_iter:
                  f.write("%s\n" % link)
      except OSError as e:
          raise SphinxError('cannot write sitemap.txt, reason: %s' % ef build_finished(app, exception):
      ''' Generate a ``sitemap.txt`` from the collected HTML page links.
  
      '''
      filename = join(app.outdir, "sitemap.txt")
  
      links_iter = status_iterator(sorted(app.sitemap_links),
                                   'adding links to sitemap... ',
                                   'brown',
                                   len(app.sitemap_links),
                                   app.verbosity)
  
      try:
          with open(filename, 'w') as f:
              for link in links_iter:
                  f.write("%s\n" % link)
      except OSError as e:
          raise SphinxError('cannot write sitemap.txt, reason: %s' % e)
docs: Generate a ``sitemap.txt`` from the collected HTML page links.